1. The composition of a domain name address
Notice:
① When any of the protocol, subdomain name, main domain name, and port number do not want to be at the same time, they are counted as different domains;
② Different domains request resources from each other, even if they are cross-domain
③ For example
2. Methods
1. Proxy (background method)
2.jsonp
A: Principle:
a domain name declaration, b domain name call, such as:
<script>
function jsonp(json){
alert(json["name"]);
}
2.jsonp
A: Principle:
a domain name declaration, b domain name call, such as:
<script>
function jsonp(json){
alert(json["name"]);
}
</script>
<script src="http://www.bbb.com/jsonp.js"></script>
B. Use
Note: jsonp only works with get method, it cannot be encrypted
C: XMLHttpRequest Level 2 provided by H5
Note:
1. ie10 and below do not support
2. Do some small modifications on the server side:
header("Access-Control-Allow-Origin:*");//Set the * number to be accessible everywhere, set the name Only the currently set
header can be accessed ("Access-Control-Allow-Methods:POST,GET")
1. ie10 and below do not support
2. Do some small modifications on the server side:
header("Access-Control-Allow-Origin:*");//Set the * number to be accessible everywhere, set the name Only the currently set
header can be accessed ("Access-Control-Allow-Methods:POST,GET")