Do front-end, with Ajax to get data, is often the case, the same domain naturally no problem, if it is different domain to obtain data, the browser has a homologous policy restrictions.
Origin * isn't allowed by access-control-allow-origin
If your browser is chrome, then there's the gospel. After opening the address of Chrome --args --disable-web-security
, you can block secure access [--args: This parameter is optional], and then randomly invoke the data under different domains.
The target for modifying the shortcut is:
"C:\Program files\google\chrome\application\chrome.exe" --args--disable-web-security
Test:
Code:
<HTML><Body>data returned from che.pingan.com:<DivID= "RLT"></Div></Body><Scriptsrc= "Http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></Script><Script>$.ajax ({type:"GET", URL:"http://che.pingan.com/shoppingCart/getMemberCartCount.do", Success:function(data) {$ ("#rlt"). HTML (data); Alert ("Success Data:" +data); } });</Script></HTML>
Before modification:
After modification:
Use Chrome to tune requests that are not in the same domain