First, JSONP
JQuery JSONP:
0> Dynamic Script
var script = document.createelement (' script '= '' http://...? Function_defined_on_server=my_callback_function '; document.head.appendChild (script); function my_callback_function (data) { // ... }
1>
$.ajax ({
URL: "http//...",
Type: ' GET ',
DataType: ' JSONP ',//here
Success:function (data) {
}
});
2>$. Getjson("http://... ", function(data) { < Span class= "hl-quotes" > }) < Span class= "hl-quotes" > 3>
$.ajax ({
URL: "http//...",
Type: ' GET ',
DataType: ' JSON ',
crossdomain:true,//default: false for same-domain requests, true for cross-domain requests
})
.done(function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});
< Span class= "hl-quotes" >
/span>
Second, the server Agent
Initiates a request on the server side to the off-site resource and then provides the resulting data to the client on the site.
Three
JavaScript Cross Domain