0

been having trouble with this script, ive managed to get it working in ie8, works on chrome fine.

initilize: function(){ $('#my_form').submit(function(){ if ($.browser.msie && window.XDomainRequest) { var data = $('#my_form').serialize(); xdr=new XDomainRequest(); function after_xhr_load() { response = $.parseJSON(xdr.responseText); if(response.number =="incorrect format"){ $('#errors').html('error'); } else { $('#errors').html('worked'); } } xdr.onload = after_xhr_load; xdr.open("POST",$('#my_form').attr('action')+".json"); xdr.send(data); } else { $.ajax({ type: "POST", url: $('#my_form').attr('action')+".json", data: $('#my_form').serialize(), dataType: "json", complete: function(data) { if(data.statusText =="OK"){ $('#errors').html('error'); } if(data.statusText =="Created"){ response = $.parseJSON(data.responseText); $('#errors').html('Here is your code:' +response.code); } } }); } return false; }); } 

I understand that ie7 does not have the XDomainRequest() object. How can I replicate this in ie7.

Thanks, in advance

2
  • Maybe your looking for JSONP, see stackoverflow.com/questions/3506208/jquery-ajax-cross-domain Commented Oct 17, 2012 at 16:37
  • Simple answer is you can't replicate it in IE7 without changing to a same-domain request or using JSONP rather than CORS. Commented Oct 17, 2012 at 17:32

1 Answer 1

4

You are not going to get that code to work in IE7 since is cross domain calls are not supported in that old browser. You either need to change the backend to do a JSONP call or you need to use a serverside proxy.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer, i figured as much.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.