Mozilla s own specification says simple GET
or POST
should be natively CORS s without preflighting but so far every POST
attempt I ve made has resulted in an OPTIONS
header going out. When I change it from POST
to get the code immediately sends a proper GET
request so the cross site part is working fine.
Here s a slimmed down sample of what I m doing in firefox:
var destinationUrl = http://imaginarydevelopment.com/postURL ;
var invocation = new XMLHttpRequest();
if (invocation) {
invocation.open( POST , destinationUrl, true);
//tried with and without this line
//invocation.setRequestHeader( Content-Type , application/x-www-form-urlencoded );
invocation.onreadystatechange = (function Handler() {
if (invocation.readyState == 4)
alert( Request made );
});
invocation.send(/* tried with and without data*/);
}
Here s what I already had working in chrome and IE:
var destinationUrl = http://imaginarydevelopment.com/postURL ;
var destination = { url: destinationUrl, type: POST , success: AjaxSuccess, error: AjaxError,
dataType: text , contentType: application/x-www-form-urlencoded
};
destination.data = { rows : rowList, token : token };
$jq.ajax(destination);