Ticket #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: | |
| Blocking: | Blocked by: |
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
comment:1 in reply to: ↑ description Changed 4 years ago by jzajpt
comment:2 Changed 3 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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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: