Good programmers web front-end share Jsonp Detailed route learning, Jsonp principle:
Let's take a look at the data transmission position POST:
GET data transmission position
That cross-domain what happens then?
When this data requests on the server: cross-domain occur;
When the local server data cross-domain requests from other servers back to occur;
Why do cross-domain?
Origin policy: security considerations browser-based, there is a contract between the various browser vendors, this convention is called the same-origin policy. This agreement is the main content of data between domains and domain are not common.
Cross-domain use what is?
When the site to grow and develop to a certain point of time, will create a lot of nodes, each node's IP is different, so cross-domain problems arise.
When the testing phase of the machine data and IP is not universal time, then cross-domain problem also occurs.
Why cross-domain?
Because you want to get data from other domains;
The principle of cross-domain JOSNP resolved.
JOSNP
What JSONP is that?
Speaking JSONP have to talk about the programmer
JSONP is great programmers struggle with the security policy of the invention;
JSONP is to call the function in the URL;
function handle(res){
alert(res.city+":"+res.region_name+":"+res.ip)
}
var script=document.createElement('script');
script.src='http://freegeoip.net/json/?callback=handle'
window.onload=function(){
body.appendchild(script)
}