I have series of ajax calls, I want that when the calls get completed the page reloads , I am doing this
function verifyFrnds() {
var boxes = $(".matchFrnds:checked").length;
//alert(boxes);
var call = 1;
$(".matchFrnds").each(function (index) {
if ($(this).is(':checked')) {
call++;
var sendData = $(this).val();
$.post('AJAX PAGE', {
sendData: sendData
}, function (data) {
//window.location.reload();
});
//alert(call);
//alert(call + ' ' + boxes + ' ' + (call >= boxes));
if (call >= boxes) {
// window.location.reload();
alert("I am executed");
}
}
});
}
so If I do alert, then all the ajax calls are exexuted and I am shown an alert message, but If I do window.localtion.reload()
then after few ajax calls the page get reloaded, which should be reloaded after ALL
calls. My main purpose is to reload the page when all calls are done.Any idea what I am doing wrong.
There is already a question on SO but it didn't help me much.