i want to update $.ajax method of jQuery so it have default timeout of 20 seconds and upon timeout i want to call my own function
and i also want to create network error function.
is this possible ?
i want to do this because i don’t want add timeout in all my $.ajax request.
Please ask query if you have any
like this for every function it’s require me to add timeout.
$.ajax(
{
url: "getDuctions.php",
type: "POST",
data: {dept_cd: dept, filter: "payroll_struct_empl_map", primary: "empl_cd"},
beforeSend: function() {
$("#duct").html("<option value=''>Loading</option>");
},
success: function(data) {
$("#duct").html(data);
},timeout:20000,
}
);
Default options can be declared using $.ajaxSetup()
Update: you can also have default functions in ajaxSetup