I cant understand how can I enable CORS while using Ajax to send information to a remote server located on another domain. I read a lot about that and many other questions on Stackoverflow but something just doesnt add up. I know that in order to bypass the security check of the browser I need to add a Access-Control-Allow-Origin: * header to my code, but where exactly? I know there is another option to add this header as a simple tag in a PHP file and then create a POST message using curls, but I'm not proficient with PHP as I am with JS. Can someone help me understand how should this be done? Important to say, I cant configure or change the servers settings, so everything must be done in the client side.
This is my code so far. I managed to get this message through using Chrome plugin, but obviously this isn't good enough since I cant recreate what the plugin is doing.
$.ajax({ type: "POST", url: "someURL", data: {name: "John", lastName : "Johnson", state : "NYC" }, headers: { "Access-Control-Allow-Origin: *" } }) .done(function( msg ) { console.log(msg); });