Results 1 to 2 of 2

Thread: setInterval not working

  1. #1
    Join Date
    Sep 2008

    setInterval not working

    I am running the same code (it works anywhere, but not in IE, but this is another thread issue) and everything is OK, excluding the fact, that when my script loads everything is OK for the first initial execution, but it is not repeating its execution as I have defined in window.setInterval. Do you have any idea why is this? How can I make this script to run in the desired interval after the oage has loaded? 10x in advance!
    HTML Code:
    <script type="text/javascript" src="js/json.js"></script> 
    <script type="text/javascript" src="js/ajax.js"></script> 
    <script type="text/javascript"> 
    Ajax chained select
    Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
    written by Alf Magne Kalleland.
    Alf Magne Kalleland, 2006
    Owner of DHTMLgoodies.com
    var ajax = new Array();
    function loadjson()
    document.getElementById('loader').style.display = 'block';
    		var index = ajax.length;
    		ajax[index] = new sack();
    		ajax[index].requestFile = './lolo/cash/noprevod/indexxjson.json';		// Specifying which file to get
    		ajax[index].onCompletion = function(){ showme(index) };	// Specify function that will be executed after file has been found
    		ajax[index].runAJAX();		// Execute AJAX function
     function showme(index)
    var jsonIneedYou = (ajax[index].response);	// Executing the response from Ajax as Javascript code
    var jsonIhaveYou = jsonIneedYou.parseJSON();
    var kolko = jsonIhaveYou.maininfo.length;
    var toshowindiv = '';
    for(var a=0; a<kolko; a++) { // cikal parvenstva
    var kolko2 = jsonIhaveYou.maininfo[a].matches.length;
    toshowindiv+= '<div class="bar">\n <span class="psh_left">';
    toshowindiv+= jsonIhaveYou.maininfo[a].name;
    toshowindiv+= "\n</span><a style=\"color:#ffffff;\" class=\"standings\" href=\"javascript:;\" onClick=\"window.open('stats.php?champ="  + jsonIhaveYou.maininfo[a].code +  "', 'myWin', 'scrollbars=yes, width=525, height=710');\" alt=\"Класиране\">Класиране</a></div> \n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
    for(var b=0; b<kolko2; b++) { //cikal ma4ove
    var color = '';
    if (b%2 == 0) color = '#ffffff';
    else {
    color = '#f4f7f4';
    var bb = b+1;
    toshowindiv+="<tr style=\"background-color:"  +color+  "\" onMouseover=\"this.style.backgroundColor='#82d700'\" onMouseout=\"this.style.backgroundColor='"  +color+  "'\"><td width=\"115\" align=\"center\">";
    toshowindiv+= jsonIhaveYou.maininfo[a].matches[b].date + '</td>';
    toshowindiv+= jsonIhaveYou.maininfo[a].matches[b].status;
    toshowindiv+= '<td width="183" align="right">' + jsonIhaveYou.maininfo[a].matches[b].team1 + '</td><td align="center" width="45"><a href="javascript:;" onClick="window.open(\'game.php?teams=' +
    jsonIhaveYou.maininfo[a].matches[b].goals + "&code=" + jsonIhaveYou.maininfo[a].matches[b].c +
    "', 'myWin', 'scrollbars=yes, location=no, width=720, height=508');\">" + jsonIhaveYou.maininfo[a].matches[b].res1 +
    "</a></td><td width=\"45\" align=\"center\">" + jsonIhaveYou.maininfo[a].matches[b].res2 +
    '</td><td width="183" align="left">' + jsonIhaveYou.maininfo[a].matches[b].team2 +
    '</td><td width="25" align="left"><a href="javascript:;" onClick="window.open(\'h2h.php?c=' + jsonIhaveYou.maininfo[a].matches[b].c +
    '&n=' + jsonIhaveYou.maininfo[a].matches[b].n +
    "', 'myWin', 'scrollbars=yes, width=958, height=710');\" title=\"Статистика\"><img src=\"images/---statistic.png\" border=\"0\" width=\"25\" height=\"17\" title=\"Статистика\" /></a></td></tr>";
    toshowindiv+= "</table>";
    document.getElementById('matches').innerHTML = toshowindiv;
    document.getElementById('loader').style.display = 'none';
    <script type="text/javascript"> 
    window.onload = function(){
    window.setInterval(function(){ loadjson(); }, 6000);

  2. #2
    Join Date
    May 2006
    Somewhere behind your screen
    setInterval("loadjson()", 6000);

    doesn't this work?
    signature under construction

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center