Ajax obtains the response parameters of the php page, controls Assignment Method, and ajax assignment.

Source: Internet
Author: User

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 ~

Related Article

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.