Note that there are some explanatory texts on larger screens.

plurals
  1. POIntermittent jQuery Errors
    primarykey
    data
    text
    <p>I'm having some odd and intermittent errors, which I assume are related to my jQuery. I made a simple content preloader that renders all the images for an application and then displays the content once it is completed. Below is the script:</p> <pre><code>&lt;?php $i=0; $handle=opendir('images'); while(false!==($file=readdir($handle))) { if($file!="." &amp;&amp; $file!=".." &amp;&amp; $file!=basename(__FILE__)) { ?&gt; &lt;img class="image_preload hidden" src="&lt;?php echo $app_info['image_url'].$file; ?&gt;"&gt;&lt;/img&gt; &lt;?php $i++; } } ?&gt; &lt;script&gt; max_loaded=&lt;?php echo $i; ?&gt;; $('.image_preload').bind({'load':function(){preloadCounter();},'error':function(){preloadCounter();}}); &lt;/script&gt; function preloadCounter() { total_loaded++; $('#loading_percentage').text(Math.floor((total_loaded/max_loaded)*100)); $('#loading_bar').css('width',Math.floor((total_loaded/max_loaded)*100)+'%'); if(total_loaded==max_loaded &amp;&amp; max_loaded&gt;0) { $('#load_display').hide(); $('#app_display').show(); setCanvasSize(); runOnStart(); } } </code></pre> <p>The PHP code runs first, of course. The script searches through the <code>images</code> directory and renders all the images and hides them. <code>$i</code> is incremented when an image put into the page.</p> <p>When this is done, it is supposed to set off the event listener (tied for both 'load' and 'error') at the bottom of the page. It first sets the <code>max_loaded</code> var to the amount of images put into the page and then the listener should trigger.</p> <p>The jQuery then modifies a loading bar according to how far along a JS var is incremented. When it the page is done loading or is through with errors, it should display my application's content.</p> <p>This works on occasion, with most errors coming from IE. I have had reports from several users that it fails across all latest browsers. Strangely enough, it works fine for others in the latest browsers.</p> <p>Is there something I'm missing here? I do get the error on occasion in IE, but there are never any errors displayed in Dev Mode. I'm at a loss.</p> <p>The problem is that it will load some content, but not all. The loading bar ends up stalling at any percentage. Sometimes it'll go through, sometimes it won't.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload