I'm making a request to a php file. The response is processed in .done(function(msg){}); and .fail this works fine. But sometimes the request gets an error. I made a retry for this. The retry also works. But if the first time fails and it is successful in de 2 or 3 try my request.done doesn't fire (in firebug I can see that is was successful)
My request:
var request = $.ajax({
url: "wcf.php",
type: "POST",
dataType: "xml",
async: false,
timeout: 5000,
tryCount: 0,
retryLimit: 3,
data: { barcode: value, curPrxID: currentPrxID, timestamp: (new Date).getTime()},
error: function (xhr, ajaxOptions, thrownError) {
if (xhr.status == 500) {
alert('Server error');
}
this.tryCount++;
if (this.tryCount < this.retryLimit) {
$.ajax(this);
//return;
}
}
}) ;
And this is the .done and fail:
request.done(function(msg)
{
$(msg).find("Response").each(function()
{
// my code here
});
});
request.fail(function(jqXHR, textStatus, errorThrown)
{
$("#message").html(errorThrown);
});