I have a form where i post data to a webagent which is on another domain(the form is on localhost and the post is to a http://thisisnotareallink.com)
If i use:
<form id="msform" action="http://thisisnotareallink.com"method="post">
then it works and i get data like bla=2&dsaf=2
but if i use:
<form id="msform" method="post">
and then in script have something like:
var xhr = new XMLHttpRequest();
xhr.open(form.method, 'http://thisisnotareallink.com', true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
// send the collected data as JSON
xhr.send(JSON.stringify($('#msform').serializeObject()));
or
$.ajax({
url: "http://thisisnotareallink.com",
type: "POST",
dataType: "json", // expected format for response
contentType: "application/json", // send as JSON
data: JSON.stringify($('#msform').serializeObject()),
then if i check the chrome inspector > Network > XHR then i get:
No 'Access-Control-Allow-Origin' header is present on the requested resource
why is this so ?