How to solve the problem of cross-domain ajax of (turn)

Original link: https://www.cnblogs.com/sunxucool/p/3433992.html

 

What is cross-domain

The problem stems from the cross-domain JavaScript same origin policy that only protocol + hostname + port number (if present) are the same, allow mutual access. That JavaScript can access and manipulate resources under their own domain, you can access and manipulate resources in other domains. For cross-domain problem is the JS and ajax, html does not have cross-domain problem, such as a label, script tag, label or even form (directly cross-domain transmit data and receive data), etc.

json

{
    "message":"获取成功",
    "state":"1",
    "result":{"name":"工作组1","id":1,"description":"11"}
}

jsonp

callback({
    "message":"获取成功",
    "state":"1",
    "result":{"name":"工作组1","id":1,"description":"11"}
})

In the url callback parameter is passed to the background of what callback is what, jsonp how a layer than outside json, callback ().

 

Guess you like

Origin www.cnblogs.com/supredreamer/p/11593378.html