0

I am trying to trigger a page reload after bunch of ajax calls have been completed. Following is the code:

var calls = jQuery.map(urls, function(url) {
  return $.post(url);
});
$.when(calls)
  .done(function() {
    window.location.reload();
  });

This code is almost always seem to trigger reload before all ajax requests complete and I see in Firebug that some ajax requests are getting cancelled. What am I missing?

Thanks.

Bhargava
  • 189
  • 3
  • 12

1 Answers1

-1

Use $.then such as;

$.when(eventHandler1).then(eventHandler2).done(function(){
 window.location.reload();
});
Subliminal Hash
  • 13,614
  • 20
  • 73
  • 104