Sonp principle:
First register a callback with the client and then pass the callback name to the server.
At this point, the server becomes JSON data.
Then, in JavaScript syntax, a function is generated, and the function name is the parameter Jsonp passed up.
Finally, the JSON data is placed directly into the function in the form of a parameter, so that a document of JS syntax is generated and returned to the client.
The client browser parses the script tag and executes the returned JavaScript document, where the data is passed in as a parameter to the client's pre-defined callback function. (Dynamic execution callback function)
One
function Getsitedata (Idsite, Lastminutes,index) {
$.ajax ({
Cache:false,
Type: "Get",
URL: "Http://baidu.com/index.php?module=API&method=Live.getCounters&format=JSON&token_auth= 5450d4c72203c278e6ff67cd40bdd9ac&idsite= "+ idsite +" &lastminutes= "+ lastminutes +" &jsoncallback=? ",
DataType: "Jsonp",
Success:function (data) {
$ ("#readvisits" + Index). Text (data[0].visits);
$ ("#readvisitors" + Index). Text (data[0].visitors);
}
})
}
Two