I just discovered there is a Ajax success handler, which is great because its automated! but I'm unsure if it is suitable for my use-case.
I'm making many ajax calls and mostly programatically (without user clicks etc) so I don't really want to bind functions to a html element.
This is how I'm doing things ATM but I'd like to automate the process. The key thing is that the method must get called before everything else and if I catch something then I don't want execution in my response handler to execute.
function GetSomeData() {
$.getJSON("/ajax/getsomedata",GetSomeDataResponse);
}
function GetSomeDataResponse(response){
if(DoesServerResponseIndicateError(response)) {
//Continue
}
}
function DoesServerResponseIndicateError() {
//see if it contains any custom errors, if it does, Don't execute the //continue block
}