In Firefox, after ajax call in jQuery, 302 redirect callbacks are not called

I have a Rails application that uses ajax extensively. With jQuery. For example, one of the models is fully controlled using jQuery: records are created, updated and deleted ajaxly. Evertything works great except for updating records.

I did some testing, and I realized that jQuery on Firefox (3.6 on Mac, 3.5 on Windows is what I tested) has problems detecting a server response when it 302 is redirected to the same URL . What I get in Firebug:

POST localhost: 3000 / resources / 1 → 302 Found

GET localhost: 3000 / resources / 1 → 200 OK

And jQuery ajax callback is not called. Neither success, nor complete, nor errors. But when I create an entry and the server redirects to another URL, the "callback" is called:

POST localhost: 3000 / resources → 302 Found

GET localhost: 3000 / resources / 1 → 200 OK

It doesn't matter if I can call $ .ajax myself or use jquery.form ajaxForm ().

Any ideas?

+3
source share
1 answer

The 301/302/303 redirect is performed by the XmlHttpRequest handler of browsers, not jQuery. This does not explain why you do not have a callback. But this may explain why the redirect is not verified on the ajax side.

, 302 , , 301 303. 303- . , GET ( ).

, ( , ).

302, , , , : ajax. HTML-, ( ), ( JSON?), json-, , , URL- ..

+1

Source: https://habr.com/ru/post/1784196/


All Articles