The example in this article describes how Jquery+ajax implements Cross-domain requests. Share to everyone for your reference. The implementation methods are as follows:
Description: Here the datatype is "JSONP"; type can only be a get
The front request code is as follows:
Copy Code code as follows:
$.ajax ({
Type: "Get",
URL: "Http://www.xxx.com/Rest/ValidAccountsExists.aspx?accounts=admin",
DataType: "Jsonp",
JSONP: "Jsoncallback",
Success:function (Result) {
Alert (result. Success);
Alert (result. Content);
},
Error:function (result, status) {
Handling Errors
}
});
The background processing code validaccountsexists.aspx as follows:
Copy Code code as follows:
String accounts = gamerequest.getquerystring ("accounts");
String jsoncallback = gamerequest.getquerystring ("Jsoncallback");
Response.ContentEncoding =system.text.encoding.utf8;
Response.ContentType = "Application/json";
Response.Write (Jsoncallback + "({\ success\": \ "true\", \ "content\": \ "" + accounts + "\"}));
Response.End ();
I hope this article will help you with your jquery programming.