views:

88

answers:

2

For some reason, only in IE (tried 7 & 8), jQuery is performing a POST request when it should be a GET. See below:

function(...) {
  /* ... */
  $.ajax({
    type: 'GET',
    dataType: 'script',
    url: '/something/' + id,
    processData: false,
    data: 'old_id=' + oldId,
    success:function(data) {
      alert(data);
    }
  });
  /* ... */
}

All browsers properly GET, but IE is performing a POST. Why?

A: 

This is most likely the cache issue for your previous request(s) in that format, add cache:false to the ajax function and hopefully it should be fine:

function(...) {
  /* ... */
  $.ajax({
    type: 'GET',
    cache:false, // this needed for IE
    dataType: 'script',
    url: '/something/' + id,
    processData: false,
    data: 'old_id=' + oldId,
    success:function(data) {
      alert(data);
    }
  });
  /* ... */
}
Web Logic
A: 

Turns out the problem was by appending parameters in the call to $.ajaxSend(), which causes the jQuery library to convert POST requests to GET requests in IE. Here's more info regarding the solution I came across:

http://www.justinball.com/2009/07/08/jquery-ajax-get-in-firefox-post-in-internet-explorer/

Matt Huggins