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