¿Es posible verificar el tiempo de espera en jQuery.post ()?
Tengo este código que solicita información de carpeta de una base de datos mysql:
function gotoDir(pmcat_id, pcat_id){
$('#slideshowContainer').html('<img class="loader" src="/javascript/ajax-loader.gif">');
$.post("/publish/includes/content.includes/functions.slideshow.php",
{ updateSlideshowDir: 1, pmcat_id: pmcat_id, pcat_id: pcat_id },
function(data){
$('#pageSlideshow').html(data.content);
}, "json"
);
}
A veces, la solicitud de publicación se agota debido a una mala conexión a Internet. ¿Es posible establecer una verificación de tiempo de espera en $ .post ()? Ej: si $ .post () usa más de X ms, vuelva a cargar la solicitud.
ACTUALIZACIÓN: Parece que encontré una solución:
function gotoDir(pmcat_id, pcat_id){
$('#slideshowContainer').html('<img class="loader" src="/javascript/ajax-loader.gif">');
$.ajax({
type:"post",
url:"/publish/includes/content.includes/functions.slideshow.php",
data: { updateSlideshowDir: 1, pmcat_id: pmcat_id, pcat_id: pcat_id },
dataType: "json",
success:function(data) {
if (data == null){
alert('ajax failed. reloading...');
gotoDir(pmcat_id, pcat_id);
} else {
$('#pageSlideshow').html(data.content);
}
}
});
}
¿Es esta una buena forma de hacer esto? : S