0

What I'm trying to do, is get the form data submitted on a form, and send this data as a POST request to another URL. It works fine on Chrome, Safari and Firefox and on IE 7,8,10 and 11, but fails on IE9! It doesn't even send any post request at all. Anyone have any idea?

The code:

$( ".submitbtn" ).on( "click", function(event) {
event.preventDefault();
//$('.submitbtn').attr('disabled', 'disabled');

var formdata = $( "form" ).serialize();
//var filedata = $('#Attachment').val();
var filedata = encodeURIComponent($('#Attachment').val());
var senddata = formdata + '&file=' + filedata;

$.ajax({
  type: "POST",
  url: "http://externalurl.com",
  data: senddata
}).done(function (data) {

    $( "form" ).submit();       

});

});

Rehan Aslam
  • 241
  • 3
  • 12

1 Answers1

2

This may be a duplicate of this question here IE9 jQuery AJAX with CORS returns "Access is denied"
Basically its a CORS (cross origin resource sharing) issue and that IE9 doesnt use the XMLHttpRequest object that all the other browsers use. (Yay! Go IE!). Anyway hopefully you should find a solution on that page.

Community
  • 1
  • 1
Craicerjack
  • 6,203
  • 2
  • 31
  • 39
  • Thank you! Solved the issue from using the plugin mentioned on that page ( https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest ). – Rehan Aslam Jul 10 '14 at 10:16