Reputation: 4202
I have user entered data that is being posted to different domain and a different protocol. After doing some reading, I discovered that Microsoft's XDomainRequest
object doesn't allow for cross-origin interactions (Different protocols, ports, #7 here.
I'm doing a standard CORS AJAX call for FF, Safari, and Chrome (which works), and I've been trying to use the XDomainRequest object for IE9.
if ($.browser.msie && window.XDomainRequest) {
var xdr = new XDomainRequest();
xdr.open("post", "https://_url_here");
xdr.send( post_data );
}else { $.ajax(params); }
When I opened an https
version of the origin site, it successfully sent data to the receiving url, but it couldn't parse any of the data. xdr.send(post_data);
"looks" like when it's being sent, I wasn't able to find info on that or see it in the console. I looked at this but couldn't quite get it; console responded: Unable to get value of the property 'postMessage': object is null or undefined
if ($.browser.msie && window.XDomainRequest) {
var domain = $("iframe").contentWindow;
domain.postMessage( post_data );
}else {
$.ajax(params);
}
Can anyone offer me some help with this?
Upvotes: 3
Views: 1601
Reputation: 4202
download the script here: https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
include it in your html after your link to jquery, but before the script where you are making the ajax call.
in a rather janky way, I used this script to send the request to my app run on heroku (http -> http = works fine), then had a sinatra app running at the heroku site that then sent the data on to the https site. not pretty, but it works.
Upvotes: 1