Reputation: 65
Here is my ajax call
$.ajax({
url: "getProduct",
type: "POST",
dataType: "xml",
data: {
productid: $("#serviceequip1").val()
},
error: function(){
},
success: function(xml){
$(xml).find("product").each(function()
{
//do something..
});
}
});
I have checked in development mode of browser, sometimes it shows 505 error for ajax call.
Please suggest some solutions.
Upvotes: 1
Views: 3151
Reputation: 436
Define a function to do ajax call. When error, call the function again.
function getProduct(){
$.ajax({
url: "getProduct",
type: "POST",
dataType: "xml",
data: {
productid: $("#serviceequip1").val()
},
error: function(){
setTimeout(getProduct, 200);
},
success: function(xml){
$(xml).find("product").each(function()
{
//do something..
});
}
});
};
Upvotes: 1
Reputation: 977
Just write this ajax call inside a method and in the failure block of ajax just call the method again.
function ajaxCall(){
$.ajax({
url: "getProduct",
type: "POST",
dataType: "xml",
data: {
productid: $("#serviceequip1").val()
},
error: function(){
ajaxCall();
},
success: function(xml){
$(xml).find("product").each(function()
{
//do something..
});
}
});
}
Upvotes: 0