Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninterruptable ajax request

Sometimes I have to AJAX a huge JSON payload (~20MB). During this process it seems like the browser window is constantly loading (latest Chrome, Windows 8.1). The user can click on things, like links, but the browser won't actually go to those links until the AJAX request completes. This can be a problem because if you go to a page that requires such an AJAX call, it is difficult to navigate away. Unfortunately at this time I cannot reduce the size of the payload much (I am loading graphs, and sometimes the graphs are hundreds of thousands of nodes and edges).

Any idea why the browser won't navigate away (even though the browser is responsive)? And, if possible, any potential solutions? Thanks!

like image 876
tau Avatar asked Dec 12 '13 19:12

tau


People also ask

What is meant by AJAX request?

AJAX stands for Asynchronous JavaScript And XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with servers. It can send and receive information in various formats, including JSON, XML, HTML, and text files.


2 Answers

I would suggest using the an HTML5 Web Worker. The browser support is not great, especially for IE.

Web workers are non-blocking, meaning you can run two scripts concurrently. This should free up your DOM while you are making the AJAX call in the background.

Here is one article I could find on using web workers with an AJAX call.

like image 152
James Avatar answered Sep 18 '22 14:09

James


I don't know how to address the exact technical problem you are facing. However this can still be useful. Consider Google or Facebook where you can download your full profile as an archive with the all your history and photos. Take a note on how they do it (not through AJAX calls). I believe they chose this way because of the very same problems you have. Just somthing to think about.

like image 27
Trident D'Gao Avatar answered Sep 21 '22 14:09

Trident D'Gao