Php, js, handling array problems

Source: Internet
Author: User
Php and js are beginners who are dealing with arrays. some of them do not understand. After I use ajax to process PHP, I return an Array like this (& nbsp; [0] = & gt; Array & nbsp; (& nbsp; [0] = & gt; 2 & nbsp; [id php, js, handle array problems
For beginners, I don't understand. I use ajax to process PHP and then return such an array.
Array
(
[0] => Array
(
[0] => 2
[Id] => 2
[1] => James
[Name] => James
)
[1] => Array
(
[0] => 3
[Id] => 3
[1] => Li Si
[Name] => Li Si
)
)
How can I not retrieve the array value from the value returned by Ajax using JS? is it wrong to retrieve the value [0] [0? How can we obtain the value?

------ Solution --------------------
We recommend that you search for an instance whose php ajax returns JSON data.
------ Solution --------------------
Use the json_encode () function to process the array you returned, and then return it to the front-end js for use. no error will occur.
------ Solution --------------------
It is best to convert it to json format. It is more convenient to receive data using js.

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.