3

In Magento I am calling a long time running function using Ajax. When I open any admin page in a new tab it shows "continue loading" until the Ajax request is completed in the previous tab.

I want to continue my work on other tabs while the Ajax process is running on one tab, how can I do it?

1 Answer 1

4

The problem is that Magento closes (writes) the session not before the request completes. That means another request with the same session (from the same browser) in the same browser has to wait until the other request finished, because the session file is still locked.

To prevent this, you can close the session in your Ajax controller as soon as you don't need it anymore:

session_write_close();
unset($_SESSION);

I did this in Hackathon_IndexerStats for reindexing via AJAX and it works like a charm. Of course you should not access any session model afterwards.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.