How JavaScript handles PHP's return to JSON-formatted data, as described below in an example!
Suppose PHP returns an array of the following:
$arr = Array (' name ' = ' Qianyuqianxun ', ' nick ' = ' thousand and Chihiro ', ' Contact ' =>array (' website ' = '/' Www.phpernote.com '), Array (' name ' = ' Qisha ', ' nick ' = ' seven evil spirit ', ' email ' = ' yhm.1234@163.com ', ' contact ' + = Array (' website ' = ' http://www.baidu.com '));p Rint_r (Json_encode ($arr)); exit;
The client JS can call the data returned as follows:
$ (document). Ready (function () {var url= ' http://www.phpernote.com/json.php ' $ (' #submitBtn '). Click (function () {$.post (URL, ', function (msg) {var myobject=eval (' (' +msg+ ') ');//msg is the returned type as a string, converted to a JSON object var str= '; var len=myobject.length; for (i=0;i
<>
' +myobject[i].name+ ' +myobject[i].nick+ ' +myobject[i].contact.website+ ';} $ (' #feedbackTable '). html (str);})})
Articles you may be interested in
- How jquery handles JSON data
- PHP digital format, numbers every three bits plus commas
- MySQL queue for efficient concurrent read data
- jquery+html+php implement Ajax no-refresh file upload
- Use MySQL database indexes reasonably to make the database run efficiently
- How to use Curl's post submission data in PHP and get a summary of how to get Web page data
- PHP gets a method for each month in a certain period of time, returning an array of these months
- PHP two ways to connect to an Access database
http://www.bkjia.com/PHPjc/764170.html www.bkjia.com true http://www.bkjia.com/PHPjc/764170.html techarticle how JavaScript handles PHP's return to JSON-formatted data, as described below in an example! Suppose PHP returns the following array: $arr = Array (' name ' = ' Qianyuqianxun ', ' N ...