JS Ajax cross-domain blocked CORS header missing ' access-control-allow-origin ' (GO)

Source: Internet
Author: User

Today, when Ajax requests a domain name, it appears

Cross-origin requests have been blocked: the same-origin policy prohibits reading remote resources located in http://www.zuimeimami.com*****. (Reason: CORS header is missing ' Access-control-allow-origin ').

Workaround 1:

var url= ' http://localhost:8080/WorkGroupManagment/open/getGroupById '       + '? id=1&callback=? ';   $.ajax ({     url:url,     dataType: ' Jsonp ',     processdata:false,      type: ' Get ',     success:function (data) {       alert (data.name)     ,     error:function (XMLHttpRequest, Textstatus, Errorthrown) {       alert ( Xmlhttprequest.status);       alert (xmlhttprequest.readystate);       alert (textstatus);     }});

Workaround 2:

var url= "Http://localhost:8080/WorkGroupManagment/open/getGroupById"    + "? id=1&callback=?"; $.jsonp ({  "url": URL,  "Success": function (data) {    $ ("#current-group"). Text ("Current workgroup:" +data.result.name) ;  },  "error": function (d,msg) {    alert ("Could not find User" +msg);}  );

Solution Three:

The requested page with the following code, the best content to fill in the domain name

<meta http-equiv= "Access-control-allow-origin" content= "*" >

Workaround four, in the request controller plus

header( "Access-Control-Allow-Origin: *" );

JS Ajax cross-domain blocked CORS header missing ' access-control-allow-origin ' (GO)

Related Article

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.