jquery - Call another ajax inside ajax till first will complete -
i using jquery ajax performing operation in web. want call ajax in every seconds until first ajax response come. ajax code :-
$.ajax({ url : $(this).attr('action'), type : $(this).attr('method'), datatype: 'json', data : $(this).serialize(), beforesend: function() { var row = '<tr id="row_'+i+'">'; row += '<td>'+$('#fileid').val()+'</td>'; row += '<td>'+$('#resolution').val()+'</td>'; row += '<td>'+$('#bitrate').val()+'</td>'; row += '<td>'+$('#ndrive').val()+'</td>'; row += '<td>'+$('.type').val()+'</td>'; row += '<td>'+curr_date+'-'+curr_month+'-'+curr_year+'</td>'; row += '<td>'+hours+':'+minute+':'+second+'</td>'; row += '<td><div id="process-bar" class="process-bar" style="height: 18px;"> </div></td>'; row += '</tr>'; $('#stastistics tbody').prepend(row); $('#fileid').val(''); $('#ndrive').val(''); $('.type').val(''); $('#resolution').val(''); $('#bitrate').val(''); }, success : function(data) { if(data.status == 'error') { var html = '<span class="label label-danger">error</span>'; $("tr#row_"+i+" td:nth-child(8)").find('#process-bar').remove(); $("tr#row_"+i+" td:nth-child(8)").html(html); } else if(data.status == 'success') { var html = '<span class="label label-success">success</span>'; $("tr#row_"+i+" td:nth-child(8)").find('#process-bar').remove(); $("tr#row_"+i+" td:nth-child(8)").html(html); } }, error : function( xhr, err ) { }, }); this ajax take long time complete want show progress process. want call ajax in every second update progress data in every second. how can call ajax inside ajax till response of first ajax. help.
i this:
var progressupdater = setinterval(function() { $.ajax({ url: addresstoprogressendpoint, method: method }) .done(function(data) { //update ui progress }); }, 1000); in original ajax request in success callback, call clearinterval() on progressupdater stop
Comments
Post a Comment