Use Chrome to tune requests that are not in the same domain

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.