Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross dromain posting data in ie9 from http server to https server

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?

like image 669
Stuart Nelson Avatar asked May 08 '26 18:05

Stuart Nelson


1 Answers

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.

like image 127
Stuart Nelson Avatar answered May 10 '26 11:05

Stuart Nelson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!