How do i loop an ajax request (using jquery) and jsp
- by Mrshll187
<script>
//when page is ready do the following
$(document).ready(function()
{
//set interval of refresh
setInterval(doAjaxMethod, 1000);
});
function doAjaxMethod(id)
{
$.ajax({
url: "getStatus/"+id,
dataType: "json",
success: function(json)
{
$('#ajaxStatus').html(json.status);
}
});
</script>
<%
//How can I do something like this
int n = object.size();
for(int i=0; i<n; i++)
{
doAjaxMethod(object.getId());
}
%>
<div id=ajaxStatus> status updates here </div>