Bug Tracker

Opened 12 years ago

Closed 12 years ago

#3155 closed bug (invalid)

Request method GET in Internet Explorer 6 & 7

Reported by: jzajpt Owned by:
Priority: major Milestone: 1.3
Component: ajax Version: 1.2.6
Keywords: ie7, ajax, get, post Cc:
Blocked by: Blocking:

Description

When using Internet Explorer 6 & 7, simple code below uses POST method instead of GET (and for example in Rails causes invocation of wrong action when being RESTful):

$.get("example", function(data){
  alert(data);
});

Also, following examples use POST too instead of GET.

$.ajax({
  url: "example",
  type: "GET",
  success: function(html){
   alert(html);
  }
});
$("#example").load("example");

Change History (3)

comment:1 in reply to:  description Changed 12 years ago by jzajpt

Forgot one thing, the error is happening only when following code is present:

$(document).ajaxSend(function(event, request, settings) {
 if (typeof(AUTH_TOKEN) == "undefined") return;
   settings.data = settings.data || "";
   settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
});

Replying to jzajpt:

When using Internet Explorer 6 & 7, simple code below uses POST method instead of GET (and for example in Rails causes invocation of wrong action when being RESTful):

$.get("example", function(data){
  alert(data);
});

Also, following examples use POST too instead of GET.

$.ajax({
  url: "example",
  type: "GET",
  success: function(html){
   alert(html);
  }
});
$("#example").load("example");

comment:2 Changed 12 years ago by dmethvin

If the request includes *any* data, IE will assume POST. The $.ajax() code takes care of this for GET requests by appending settings.data to settings.url and clearing settings.data, but the global ajax events are triggered after that fix has been applied. So, on a GET request you must add to settings.url, not settings.data.

comment:3 Changed 12 years ago by dmethvin

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.