How does JavaScript process json data returned by php. How does JavaScript process json-format data returned by php? An example is provided below! Suppose php returns an array like the next one: $ arrarray (array (nameqianyuqianxun, n JavaScript: how to process php returned json-format data, we will illustrate through an example below!
Suppose php returns the following array:
$ Arr = array ('name' => 'qianyuqianxun ', 'Nick' => 'qianxun ', 'Contact' => array ('Website' => 'http: // www.phpernote.com '), array ('name' => 'qisha', 'Nick' => 'qizha', 'Email '=> 'yhm. 1234@163.com ', 'Contact' => array ('Website' => 'http: // www.baidu.com '); print_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 a string of the returned type, convert to 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 does jquery process json data?
- PHP number formatting, three digits are added with commas
- Mysql queue for efficient concurrent data reading
- Jquery + html + php implement Ajax without refreshing file Upload
- Rational Use of MySQL database indexes to make the database run efficiently
- In php, we use the curl post method to submit data and the get method to obtain webpage data.
- Php gets the method of each month in a certain period of time, and returns an array composed of these months
- Two methods for connecting PHP to access database
Http://www.bkjia.com/PHPjc/764170.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/764170.htmlTechArticleJavaScript how to handle php return json format data, below we illustrate through an example! Suppose php returns the following array: $ arr = array ('name' = 'qianyuqianxun ', 'n...