Php --- ajax transmits multi-dimensional arrays to the background

Source: Internet
Author: User
Php --- ajax transmits multi-dimensional arrays to the background

Php --- ajax transmits multi-dimensional arrays to the backend. For more information, see.


1 traditional: true

?? The online data is generally set to true as the ajax parameter traditional, so the array can be converted into a format string, but this still needs to be parsed in the background. This method is too troublesome and has not been tested.

2. convert js object (or array) to json

?? The main difference between an object and an array is that an object is an array surrounded by curly braces {}, and an array is surrounded by brackets.
?? Conversion Method: JSON. stringify (mydata)

  1. $. Ajax ({
  2. Url: 'xxxxxxxxxxxxxxxx ',
  3. Type: 'post ',
  4. DataType: 'text ',
  5. Data :{
  6. 'Rowdata': JSON. stringify (mydata)
  7. },
  8. Success: function (data ){
  9. Console. log (data );
  10. },
  11. Error: function (){
  12. Alert ("An error occurred while obtaining data! ");
  13. }
  14. });

?? After being passed to the background, the json is decoded using json_decode (data. If you can also check whether the decoded data is correct, you can use ajaxReturn () to return the data. For the t debugging method, see http://blog.csdn.net/freeape/article/details/50072069.

Php

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.