Jump to content

SetTimeout Not working ...


QUACK

Recommended Posts

I am trying to retrieve multipule and refresh them all after 5 seconds.

[code]        <div id="header">
            <img src="/images/heading3.gif">
        </div>
        <div class="news" id="news1"><!-- Empty div for dynamic content -->Loading news. please wait...</div>        
        <div class="news" id="news2"><!-- Empty div for dynamic content -->Loading news. please wait...</div>        
        <div class="news" id="news3"><!-- Empty div for dynamic content -->Loading news. please wait...</div>        

        
    </div>

<script type="text/javascript">
ajax_loadContent('news1--external/externalfile1.html');
ajax_loadContent('news2--external/externalfile2.html');
ajax_loadContent('news3--external/externalfile3.html');
[/code]

[code]function ajax_showContent(divId,ajaxIndex,data)

{

    document.getElementById(divId).innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;

    dynamicContent_ajaxObjects[ajaxIndex] = false;

    settimeout("ajax_loadContent('"+data+"')",5000);

}



function ajax_loadContent(data)

{
    data    = data.split ( '--' );

    var ajaxIndex = dynamicContent_ajaxObjects.length;

    dynamicContent_ajaxObjects[ajaxIndex] = new sack();

    dynamicContent_ajaxObjects[ajaxIndex].requestFile = data[ 1 ];    // Specifying which file to get

    dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(data[0],ajaxIndex,data); };    // Specify function that will be executed after file has been found

    dynamicContent_ajaxObjects[ajaxIndex].runAJAX();        // Execute AJAX function

}

[/code]

It loads the 3 pages then stops, it doesent do it agian after 5 seconds. If anyone has a better way of doing it, im welcome to suggestions :D

thanks.
Link to comment
https://forums.phpfreaks.com/topic/5969-settimeout-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.