How do i loop an ajax request (using jquery) and jsp

Posted by Mrshll187 on Stack Overflow See other posts from Stack Overflow or by Mrshll187
Published on 2011-06-24T14:51:35Z Indexed on 2011/06/24 16:22 UTC
Read the original article Hit count: 134

Filed under:
|
|
|
<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>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery