AngularJS performs an OPTIONS HTTP request for a cross-origin resource

I’m trying to setup AngularJS to communicate with a cross-origin resource where the asset host which delivers my template files is on a different domain and therefore the XHR request that angular performs must be cross-domain. I’ve added the appropriate CORS header to my server for the HTTP request to make this work, but it … Read more

Origin is not allowed by Access-Control-Allow-Origin

I’m making an Ajax.request to a remote PHP server in a Sencha Touch 2 application (wrapped in PhoneGap). The response from the server is the following: XMLHttpRequest cannot load http://nqatalog.negroesquisso.pt/login.php. Origin http://localhost:8888 is not allowed by Access-Control-Allow-Origin. How can I fix this problem? 18 Answers 18

What are the integrity and crossorigin attributes?

Bootstrapcdn recently changed their links. It now looks like this: <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css” rel=”stylesheet” integrity=”sha256-MfvZlkHCEqatNoGiOXveE8FIwMzZg4W85qfrfIFBfYc= sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==” crossorigin=”anonymous”> What do the integrity and crossorigin attributes mean? How do they affect the loading of the stylesheet? 3 Answers 3

jQuery AJAX cross domain

Here are two pages, test.php and testserver.php. test.php <script src=”https://stackoverflow.com/questions/3506208/scripts/jq.js” type=”text/javascript”></script> <script> $(function() { $.ajax({url:”testserver.php”, success:function() { alert(“Success”); }, error:function() { alert(“Error”); }, dataType:”json”, type:”get” } )}) </script> testserver.php <?php $arr = array(“element1”, “element2”, array(“element31″,”element32”)); $arr[‘name’] = “response”; echo json_encode($arr); ?> Now my problem: when both of these files are on the same server (either … Read more

How do I send a cross-domain POST request via JavaScript?

How do I send a cross-domain POST request via JavaScript? Notes – it shouldn’t refresh the page, and I need to grab and parse the response afterwards. 17 s 17 Update: Before continuing everyone should read and understand the html5rocks tutorial on CORS. It is easy to understand and very clear. If you control the … Read more

Access-Control-Allow-Origin Multiple Origin Domains?

Is there a way to allow multiple cross-domains using the Access-Control-Allow-Origin header? I’m aware of the *, but it is too open. I really want to allow just a couple domains. As an example, something like this: Access-Control-Allow-Origin: http://domain1.example, http://domain2.example I have tried the above code but it does not seem to work in Firefox. … Read more

How does Access-Control-Allow-Origin header work?

Apparently, I have completely misunderstood its semantics. I thought of something like this: A client downloads javascript code MyCode.js from http://siteA – the origin. The response header of MyCode.js contains Access-Control-Allow-Origin: http://siteB, which I thought meant that MyCode.js was allowed to make cross-origin references to the site B. The client triggers some functionality of MyCode.js, … Read more