0

I have these two scripts.

First:

$(document).ready(function(){
  refreshStatus();
});
function refreshStatus(){
  setTimeout(function(){
    $('#div_top_info').load('load_status.php');
  }, 2000);
}

Second:

var skill = <?php echo json_encode($skill_, JSON_UNESCAPED_UNICODE); ?>;
var skill_final = <?php echo json_encode($skill_final, JSON_UNESCAPED_UNICODE); ?>;
var camp_final = <?php echo json_encode($camp_final, JSON_UNESCAPED_UNICODE); ?>;
var jmeno = <?php echo json_encode($jmeno_, JSON_UNESCAPED_UNICODE); ?>;
var pozice = <?php echo json_encode($pozice_, JSON_UNESCAPED_UNICODE); ?>; 
var delka = <?php echo json_encode($delka_, JSON_UNESCAPED_UNICODE); ?>;
var opravneni = <?php echo json_encode($opravneni, JSON_UNESCAPED_UNICODE); ?>;

$(document).ready(function(){
  refreshPrehled();
});
function refreshPrehled(){     
  $('#checkboxes').load('load_prehled.php', {
    skill: skill,
    skill_final: skill_final,
    camp_final: camp_final,
    jmeno: jmeno,
    pozice: pozice,
    delka: delka,
    opravneni: opravneni
  }, function(){
    setTimeout(refreshPrehled, 12000);
  });;
}

Second is below first on my page. Does this mean only one setTimeout can run on one page?

And if thats the case, how do I put these two together into one script when I wanna load two different .php into two different html objects?

Thanks for help!

EDIT

Also html objects:

<div class="div_top_info" id="div_top_info"></div>
<form action="index.html" method="POST" id="checkboxes"></form>

I have tried different variations of timeouts, setInterval, different positioning, delay one of the timeouts. Really don't know. I fight this second day now.

EDIT2

Important info: Sorry bad info. They load, but into each php (load_status and load_prehled) I put this code:

$z_cas_editace = date('Y-m-d H:i', filemtime('datazelva_UL.txt'));

And second one updates the time and first one doesn't. The first function also works fine when I put it in place of second.

IRMA
  • 49
  • 5
  • Check your console - the functions arent identical. One runes within a `timeout` and calls `load_status` - the other runs in its own method and calls `load_prehled` – tymeJV Apr 29 '14 at 20:43
  • added info. Also, the first one works when I put it into the second ones place. – IRMA Apr 29 '14 at 20:47
  • Thanks to comment by Guilherme Nascimento Answer here: http://stackoverflow.com/questions/168963/stop-jquery-load-response-from-being-cached :) – IRMA Apr 29 '14 at 21:03

1 Answers1

0

Just my head spinning...

var skill = <?php echo json_encode($skill_, JSON_UNESCAPED_UNICODE); ?>;
var skill_final = <?php echo json_encode($skill_final, JSON_UNESCAPED_UNICODE); ?>;
var camp_final = <?php echo json_encode($camp_final, JSON_UNESCAPED_UNICODE); ?>;
var jmeno = <?php echo json_encode($jmeno_, JSON_UNESCAPED_UNICODE); ?>;
var pozice = <?php echo json_encode($pozice_, JSON_UNESCAPED_UNICODE); ?>; 
var delka = <?php echo json_encode($delka_, JSON_UNESCAPED_UNICODE); ?>;
var opravneni = <?php echo json_encode($opravneni, JSON_UNESCAPED_UNICODE); ?>;

$(document).ready(function(){
  refreshStatus();
  refreshPrehled();
});

function refreshStatus(){
  setTimeout(function(){
    $('#div_top_info').load('load_status.php');
  }, 2000);
}

function refreshPrehled(){     
  $('#checkboxes').load('load_prehled.php', {
    skill: skill,
    skill_final: skill_final,
    camp_final: camp_final,
    jmeno: jmeno,
    pozice: pozice,
    delka: delka,
    opravneni: opravneni
  }, function(){
    setTimeout(refreshPrehled, 12000);
  });;
}