I am a front-end developer. I'm coding only with client side so I don't know for sure about the error exist. I've searching about CORS, but still no idea what did my problem course.
I'm trying to post data to REST.
$.ajax({
     url        : urlPost,
     type       : "POST",
     data       : JSON.stringify(obj),
     dataType   : "json",
     contentType: "application/json",
     success: function(res){
         console.log(JSON.stringify(res));
     },
     error: function(res){
         console.log("Bad thing happend! " + res.statusText);
     }
});
Headers of web service show in firebug of firedfox :

It is working for all the browser that I used, except in IE 10, I got two errors:
SEC7118: XMLHttpRequest for http://mysite/project/wl.svc/AddWL/ required Cross Origin Resource Sharing (CORS). 
SEC7119: XMLHttpRequest for http://mysite/project/wl.svc/AddWL/ required CORS preflight. 
An HTTP client other than a browser won't use either the same origin policy or CORS. Requests made from these other HTTP clients don't have an origin. Unless the Postman desktop app emulates a browser it will be able to make requests to any URL.
I think you have a CORS, so I recommend you to take a look at cors-anywhere
I have used it and it works fine all what you need to append your request url to https://cors-anywhere.herokuapp.com/ which it is a Proxy server to request the chosen URL
var cors_api_url = 'https://cors-anywhere.herokuapp.com/' + urlPost;
$.ajax({
     url        : cors_api_url,
     type       : "POST",
     data       : JSON.stringify(obj),
     dataType   : "json",
     contentType: "application/json",
     success: function(res){
         console.log(JSON.stringify(res));
     },
     error: function(res){
         console.log("Bad thing happend! " + res.statusText);
     }
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With