How to process JavaScript data in json format returned by php _ PHP Tutorial

Source: Internet
Author: User
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...

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.