Cross-domain requests are like going to someone else's house to play. If they don't open the door for you, how can you enter their house. Just let the server set up a whitelist and specify those domain names that can be accessed by requests. La. You can also set the backend to accept requests under any domain name during the testing phase, and then turn off this setting after it is officially launched, but this method is not recommended.
Cross-domain requests are like going to someone else's house to play. If they don't open the door for you, how can you enter their house. Just let the server set up a whitelist and specify those domain names that can be accessed by requests. La. You can also set the backend to accept requests under any domain name during the testing phase, and then turn off this setting after it is officially launched, but this method is not recommended.
First,
jsonp
只能用于get
data.Use
jsonp
跨域获取数据的一个大前提是后端返回的数据得是一段可执行的Javascript
script, take your code above as an example, the returned content should look like this:Request Code
Return data
Otherwise I will report your mistake:
Uncaught SyntaxError: Unexpected token :
Regarding cross-domain, you should first understand what the problem is, and then build public APIs and CORS after reading this