Hi all, I have a problem. I have a menu and when clicked it loads the data from that menu into my main page divs. However, I want to be able to auto refresh my div#mainview_json every 5 seconds. When I try to implement the auto_refresh = setInterval(blah, 5000); it tends to fail :(
When it's refreshing, it's not grabbing the same array row data so it refreshes with blank data :(
function getlhm() {
$.getJSON('lhm-test.js', function (data) {
$("div#lhm_json").html('');
$.each(data.aushr, function (i,data) {
var aushrdata = '<a href="javascript:mainview('+data.id1+','+i+++');">'+data.name+'</a><br>';
$("div#lhm_json").append(aushrdata);
});
});
}
function mainview(id1,i) {
$.getJSON('lhm-test.js', function (data) {
$("div#mainheader_json").html('');
$("div#mainheader_json").append(data.aushr[i].name+'<br>'+data.aushr[i].starttime+'<br>Play: '+data.aushr[i].play);
$("div#mainview_json").html('');
$("div#mainview_json").append('id1: '+data.aushr[i].id1+'<br>id2: '+data.aushr[i].id2+'<br>Status: '+data.aushr[i].status);
})
}
var auto_refresh = setInterval(mainview, 5000)