Ajax obtains the response parameters of the php page, controls Assignment Method, and ajax assignment.
Js page
$. Ajax ({type: "get", url: "", // redirect page data: "m = content & c = favorite & a = del_favorite & shoucangId =" + _ id, // The passed parameter datatype: "html", async: 'false', success: function (data) // return value {if (data! = Null) {var str = new Array (); // defines an Array of str = data. split (","); // character segmentation var title = str [0]; var url = str [1]; var type = str [2]; var id = str [3]; $ ("# title "). val (title); // jQuery control value $ ("# url "). val (url); $ ("# shoucnag_id "). val (id); if (type = 'piano put') $ ("input [name = 'Radio '] [value = 'piano put']"). attr ("checked", true); else if (type = 'piano picture') $ ("input [name = 'Radio '] [value = 'piano picture']"). attr ("checked", true);} else {alert ('failed! '); Return false ;}}});
PHP page
$ ShoucangId = $ _ GET ['shoucangid']; // obtain the passed parameter $ where = "ID = '$ shoucangId'"; $ signalInfo = array (); $ signalInfo = $ this-> db-> get_one ($ where, '*', ','); // the example of Secondary Development of PHPCMS is used here, a dataset in the select database is saved in the array $ signalInfo if ($ signalInfo! = Null) {$ str = $ signalInfo ['title']. ",". $ signalInfo ['url']. ",". $ signalInfo ['type']. ",". $ signalInfo ['id']; // Concatenates the array to be returned into a string using commas to return exit ($ str);} else {exit ('0 ');}
The above is a small Editor for you to get php page return parameters ajax, control assignment method all content, I hope you can support a lot of help house ~