Im in the need to update several #divs on a page by using AJAX to call a function in my web app that returns a value. The value is a counter the idea is to update it in realtime this way.
function getTime(ID) returns = "12.00"
What would be a good way to implement this in query?
Im using below snippet to reload a section of a page but how to do this with multiple sections? any query guru's can help me on the right way? thx!
:javascript
var refreshId = setInterval(function() {
$("#basket").load('/gettime/<id value from id attribute to pass it???>');
}, 10000);
$.ajaxSetup({ cache: true });
Well, one way you can do it is, use one class, say "reload" to all the divs that needs to be reloaded, set unique ids to those divs and do something like:
$('body').on('reloadTimeout', 'div.reload', function(event){
//get the div id using
var divId = $(this).attr("id");
//then do some ajax stuff like load to fetch content
});
window.setInterval(function(){
body.trigger('reloadTimeout');
}, 30000);