1. Data that is queried from the database and placed in an array
The code is as follows:
$query =mysql_query ($SQL);
while ($row = Mysql_fetch_array ($query)) {
$xdata []= $row [' eventdate '];
$ydata []=intval ($row [' data ']);
}
2. Turn the data into JSON
The code is as follows:
$data _arr=array ($xdata, $ydata)
Json_encode ($data _arr);
Ajax call data in 3.HTML pages
The code is as follows:
$.ajax ({
Type: "Get",
URL: "columndata.php?r=" + Math.floor (Math.random () * 1000 + 1),
Data: {' begintime ': "+ BeginTime +" "," Endtime ":" "+ Endtime +" "," keyword ":" "+ keyword +" "},
DataType: "Text",
Global:false,
Async:false,
Success:function (Strreult) {
if (Strreult = = "-1") {alert ("fail!");
var jsondata = eval ("+ Strreult +"));
var xData = jsondata[0];
var ydata = jsondata[1];
var namestr = jsondata[2];
},
Error:function () {
Alert ("fail!");
}
});
The above mentioned is about the Json_encode use of the entire content of the method, I hope to help you.