Pretty much what the title says. I have an ajax call that works well on GET but PUT gives me the Cross Domain Error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://myDomainPC:6764/Forms/MyAction/2. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Here's the code. The url of the call goes to
"http://myDomainPC:6764/Forms/MyAction/" + (InspectionID != 0 ? InspectionID : "")
The inspection ID has a default value of 0 if it is not passed in via query string.
I've added the extended headers property based on this SO post (but no change): jquery $.ajax cross-domain GET works but not POST
$.ajax({
url: ajaxDataSaveInspectionURL,
data: pageHeader,
dataType: "json",
type: "PUT",
crossDomain: true,
headers: { "Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "accept, origin, authorization, content-type, content-length, connection, x-requested-with, user-agent"},
contentType: "application/json",
success: function(result){
//do stuff here
},
error: function(xhr, settings){
switch (xhr.status) {
case 404: //and other statuses...
//do stuff here
break;
}
}).done(function (data) {
//do stuff here too
});
Another developer has confirmed that the API we're calling is set up properly to accept requests from anywhere.
What's going on here that I need to change to get something besides an error?