I want to update the page only when the function "removeDocx" be executed. But in my case, timeout of the timer is perceived as the completion of "wait" function. Where is the problem, and how can I solve it? There is an example of code:
$(function () {
$.when(wait()).done(function () {
location.href = location.href;
});
});
function wait() {
var pm = { ISN_DOC: GetrcId(document.location.href) };
if (isNaN(pm.ISN_DOC))
setTimeout(wait, 500);
else removeDocx();
}
function removeDocx() {
var def = $.Deferred();
var url = "MinPrj/Collage.asmx/clearPattern?isn_doc=" + pm.ISN_DOC;
$.ajax({
type: 'POST',
url: rootpath + url,
contentType: 'application/json'
}).done(function (r) {
def.resolve();
}).fail(def.reject());
return def;
}