<!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 password=$('#password').val(); ?
? ? ? ? ? ? ? ? })? ? ? ? ? ? ? ? return arr1,arr2;? ? ? ? ? ? ? }? ? ? ? ? ? ?arrTest();? ? ? ? ? ?? var ?option = {? ? ? ? ? ? ? ? ? ? info-bulle?: {? ? ? ? ? ? ? ? ? ? ? ? show?: true? ? ? ? ? ? ? ? ? ? },? ? ? ? ?? ? ? légende?: {? ? ? ? ? ? ? ? ? ? ??données?:[' age']? ? ? ? ? ? ? ? ? ? },? ? ? ?? ? ? ?? ? xAxis?: [
{
Type: 'Catégorie',
Données: Arr1
}
],
Yaxis: [
{
Type: 'Value'
}
],
Series: [
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ?? ? ? ? ? ? ? ? ? "nom": "age",
? ? ? ? ? ? ? ? ? ? ? ? ? ? "type": "bar",
? ? ?? ? ? ? ? ? ? ? ? ? ? "data":arr2
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ?? ? ? ? ? ? ]
? ? ???? ? ? ? };
?? ? ? ? ? ? ?myChart.setOption(option); ?
? });
}); ? ? ? ? ??
? ? </script>
</body>
后臺
//$p = $_GET["username"];
$p=" 20180621";
用$p = $_GET["username"]接收不到前端傳來的數(shù)據(jù),但是直接賦值給變量$p,前端能正常收到j(luò)son數(shù)據(jù)
Si vous utilisez le framework tp5, directement input('post.username');
Votre type ajax ne publie-t-il pas?? Pourquoi l'arrière-plan utilise-t-il $_GET pour le recevoir?? Utilisez $_REQUEST ou $_POST.