Talking about JSON

Source: Internet
Author: User
Tags json

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",
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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.