Send a two-dimensional array in PHP to the forward table JS

Source: Internet
Author: User
Tags http post

In PHP forward a two-dimensional array of JS, and in the foreground JS receive the value of the entire process method:

(1), Method Description: The array is now sent to the foreground in the background

echo Json_encode ($result);

And then in the JS page in the Ajax of the return function to receive the transfer, the most important thing is to accept the time to set the type of receiving parameters:

$.post (
"http:" +$ (' #url '). Val () + "/search",
{Drug_name:drug_name},
Function (res) {
Alert (res[2][' Drug_format ');
alert (res.length);
var num=res.length;
var arr= new Array (num);
for (i=0;i<num;i++) {
arr[i]=res[i][' Drug_format '];
}
var o = document.getElementById ("list");
var len = arr.length;
for (var i = 0; i < len; i++) {
var op = document.createelement ("option");
Op.setattribute ("value", arr[i]);
op.innerhtml = Arr[i];
O.appendchild (OP);
}
}, ' json '//The most important thing is to set this parameter type

);

(2), the definition and usage of post

The post () method loads data from the server via an HTTP POST request.

Grammar
Jquery.post (URL,data,success (data, Textstatus, JQXHR),dataType)

Parameters Description
Url Necessary. Specifies which URL to send the request to.
Data Optional. The map or string value. Specifies the data that is sent to the server along with the request.
Success (data, Textstatus, JQXHR) Optional. The callback function to execute when the request succeeds.
DataType

Optional. Specifies the data type of the expected server response.

The default is to perform smart judgments (XML, JSON, script, or HTML).

Send a two-dimensional array in PHP to the forward table 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.