This is actually an advanced encapsulation of the previous example $.ajax ({..}).
In the server by obtaining callback parameters (such as: Web Effects onp*****) to get the jquery side of the subsequent callback
It then returns something like: "The Web Effect onp***** (" + JSON array to return + ");
jquery dynamically loads the call through the callback method: jsonp***** (JSON array);
This achieves the goal of cross domain data exchange.
JSONP is a scripting Injection (script injection) behavior, so there are some security risks
$.ajax ({
Async:false,
URL: ',//cross-domain URL
Type: ' Get ',
DataType: ' Jsonp ',
JSONP: ' Jsoncallback ',//default callback
Data:mydata,//Request data
timeout:5000,
Beforesend:function () {//jsonp mode This method is not triggered. The reason may be that datatype, if specified as JSONP, is no longer an AJAX event.
},
Success:function (JSON) {//client jquery predefined callback function that dynamically performs this callback function after successfully acquiring JSON data on a cross-domain server
if (json.actionerrors.length!=0) {
alert (json.actionerrors);
}
},
Complete:function (XMLHttpRequest, Textstatus) {
},
Error:function (XHR) {
Jsonp way This method is not triggered
Request Error Handling
Alert (Please check the correlation network condition for errors);
}
});
jquery Code
$.getjson (url+ "callback=?"),
function (JSON) {
});