javascript - jquery post call and reloading after every 5 seconds -
i doing ajax functionality want is, after every successful ajax call, div should refreshed.
currently considering of using settimeout not sure how proced ahead
here curret code
$(document).on('click','.openbrand',function(e) { var id = $(this).attr('data-id'); var name = $(this).attr('data-rel'); var info = 'name='+name+'&id='+id; $.post("update.cfm",{id:id,brand:name},function(data, textstatus, jqxhr){ }); }); <div class="reloadcounters" style="float:right; padding:10px; position:absolute;"><a href="javascript:void(0);">#fans#</a> <i style="cursor:pointer;" data-rel="#brand#" data-id="#id#" class="fa fa-heart-o openbrand"></i></div>
i want refresh reloadcounters
after result set
function refresh(){ $.post("update.cfm",{id:id,brand:name},function(data, textstatus, jqxhr){ settimeout(function(){refresh();}, 5000); }); } $(document).on('click','.openbrand',function(e) { id = $(this).attr('data-id'); name = $(this).attr('data-rel'); info = 'name='+name+'&id='+id; refresh(); document.unbind("click"); //optional, not know if needed });
javascript jquery ajax
No comments:
Post a Comment