Heim > Fragen und Antworten > Hauptteil
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>TEST</title>
<script type="text/javascript " src="js/echarts.js"></script>
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
</head>
<body>
<input type="text" id="username">
<input type="text" id="password">
< ;button id="sub">查询</button>
<span id="text"></span>
<div id="main" style="height:400px"> ;</div>
<script type="text/javascript">
$(document).ready(function(){
$("#sub").on("click",function(){
var myChart = echarts.init(document.getElementById('main'));
var arr1=[],arr2=[];
function arrTest(){
var username=$('#username'). val(); var passwort=$('#password').val(); $.ajax({
async:false,
}) return arr1,arr2; } arrTest(); var option = { Tooltip: { show: true Legende: { Daten:[' Alter'] }, xAxis : [
{
Typ: 'Kategorie',
Daten: arr1
}
],
yaxis: [
{
Typ: 'value'
}
],
Serie: [
{
"Name": "Alter",
"Typ": "bar",
"Daten": arr2
}
]
};
mychart.setoption (Option);
});
});
</script>
</body>
后台
//$p = $_GET["username"];
$p=" 20180621";
用$p = $_GET["username"]数据