javascript - Screen blocker on Long running script -



I have a simple HTML page that contains a large table that has more than 2000 rows. I find that the jquery code written to search and sort in that table takes some time to search and sorting (which makes sense) what I want to do is replace a screen barrier when searching for a script or Sorting the table. This behavior can be seen on Ajax calls on many websites, which can be obtained from the implementation of AJAXBizin and AJAX. Is there any such method that can be used to apply a screen blocker for long lasting scripts. If not, what is the alternative? Any suggestion is highly appreciated / agreed

I recommend breaking it and setTimeout I repeat with. For example, instead of:

  function example1 () {for (var i = 0; i & lt; 1000; i ++) {// some code }} You can type:  
  function example2 () {var i = 0; Assistant (); Function assistant () {// some code if (++ i and lt; 1000) {setTimeout (assistant, 0); }}}   

You are not in each callback for each instance. You can convert 1000 iterations into 1 function call to 100 iteration calls in 10 iterations for each future call or in most of your case. This idea is not to block user interfaces for so long that the user will notice.

Another idea will be the use of web workers if you can but it will not work on older browsers (which may or may not be if you are writing a browser extension or you know your users What will you use, etc.).

If you do this in the way described in your question, then during the course of your calculation the browser is completely unresponsive and you will most likely trigger a "slow script" - do you want to kill it ? Like warning

Comments