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)
- $. Ajax ({
- Url: 'xxxxxxxxxxxxxxxx ',
- Type: 'post ',
- DataType: 'text ',
- Data :{
- 'Rowdata': JSON. stringify (mydata)
- },
- Success: function (data ){
- Console. log (data );
- },
- Error: function (){
- Alert ("An error occurred while obtaining data! ");
- }
- });
?? 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