I have a written a function which in turn makes ajax calls. I have used this in all my pages.
function getFunc(fullURL, successCallback, errorCallback) {
$.ajax({
type : 'GET',
url : fullURL,
async : false,
dataType : 'json',
success : successCallback,
error : errorcallback
});
}
And call this function as follows-
getFunc(someurl,
function(data){
//display data
},
function(xhr, textStatus, errorThrown){
//display errors
}
);
This code works fine. Now I have to add some default error handling code which is for all the web pages which call getFunc(..), but I dont want to go into each web page and do it. how can I do that in getFunc(..)?
i.e I need a way to do this-
function getFunc(fullURL, successCallback, errorCallback) {
$.ajax({
type : 'GET',
url : fullURL,
async : false,
dataType : 'json',
success : successCallback,
error : do some default error handling and then call errorCallback
});
}
ajaxErrorevent?async: false? This will lock up the entire browser until the call is completed.asyncoption altogether. It's not needed.