Bug Tracker

Modify

Ticket #3932 (closed bug: wontfix)

Opened 5 years ago

Last modified 6 months ago

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

comment:1 Changed 5 years ago by dmethvin

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.

comment:2 Changed 5 years ago by john

  • Status changed from new to closed
  • Version changed from 1.3 to 1.3.1
  • Resolution set to wontfix
  • Milestone changed from 1.3.1 to 1.3.2

Yeah, I agree that this is probably something that we won't be able to handle explicitly.

comment:3 Changed 6 months ago by anonymous

I'm so glad I've found this page!!!! Spent hours trying to understand that.

Thanks!

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.