AJAX网址请求循环

how can i loop url request in ajax if i get a particular error, i will check the status in loop if the request is success then inside the loop there will be an if state ment, if success do something, if not do something... and also it must have a delay before the next url request

For example

isSuccess will hold the value if its request is sucess

While !(isSuccess=="success"){

ajax url request here

 if success {
 do someting
 }
 else
 {
 do something
 }
 delay code here
}

I hope someone can help me on how to do it?

you Can use recursion as a Ajax loop

function ajaxFunction() {
    reqUrl = "UrlString For ajax Request";
    $.post(reqUrl, function (response) {
           if (response.success) 
           {
             // Do something
           }
          else
          {
             // Do something
             ajaxFunction();
           }

    });
}

A request will only be sent when a previous request is compleated. Evan if you want delay in that you can use setTimeout(ajaxFunction,3000);