I'm using jQuery 1.6.2 to make a POST AJAX request to a page on the same domain. That page does a 302 redirect to another page.
Now, on my local machine this work fine but on our production server, the redirect is never followed and in the Chrome inspector the request is said to be 'canceled'.
If I visit the same page without involving javascript, everything works fine, and as I said the AJAX works on my local machine but not on the production server.
Does anyone know what might cause this?
There are some differences between the servers (OS X, Apache2, PHP5.3.6, HTTP on local machine, Ubuntu, Lighttpd, PHP5.3.3, HTTPS on production) but none that to me should make any difference.
The HyperText Transfer Protocol (HTTP) 302 Found redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location header.
You can follow these five steps to fix HTTP 302 errors on your website: Determine whether the redirects are appropriate or not by examining the URLs that are issuing the 302 redirects. Check your plugins to make sure any redirect settings are valid. Ensure that your WordPress URL settings are configured correctly.
When you make an AJAX request, your browser sends an HTTP request to a given address. The server on the other end of the request responds, and returns the data to your browser. This is the same thing that happens when you navigate to a new web page.
ajax appears to always follow redirects. How can I prevent this, and see the redirect without following it? There are various questions with titles like "jquery ajax redirect" but they all appear to involve accomplishing some other goal, rather than just directly checking the status that a server gives.
Turns out a bug in the redirect code caused the redirect to go to http:// while the page that was requested was https://. That makes the browser refuse to follow the redirect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With