Ticket #3932 (closed bug: wontfix)
If an AJAX POST request receives a 301 response, data is not re-POSTed to the new location
| Reported by: | Firehed | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.3.2 |
| Component: | ajax | Version: | 1.3.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I found this with help from Firebug, and get identical results in Safari as well:
If an AJAX request to a page that receives a "301 Moved Permanently" response, an empty GET request is made to the new location.
I think it's very unlikely that people will come across this, but if you miss a trailing slash on an address for example (when using nice mod_rewrite addresses), this comes up.
Sample:
jQuery.post("ajax", objectId: 'demo', function(ajaxResponse){alert(ajaxResponse);});
Firebug shows a POST request to http://mysite.com/admin/ajax (the page's html contains a <base href=" http://mysite.com/admin/" /> tag in the head) with the correct payload.
Response: 301, Location: http://mysite.com/admin/ajax/ (note the trailing slash)
The 301 prompts a GET to the location specified in the above response. The GET has no payload. The expected behavior is that the original POST response would simply re-POST to the new location.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

As I understand what happened, it doesn't sound like a bug. The .ajax() method did a POST to the requested URL and got an HTTP response of 301. The code that called .ajax() can do whatever it wants with that response, including re-posting to the given location.