I have reviewed a lot of answers to this type of question and now I am confused as to the best way. Given the latest jquery, I am wanting to
As previously mentioned, using Callbacks.
function process(url, params, successCallback, errorCallback) {
$.ajax({
success : successCallback,
error : errorCallback,
data : params,
url : url,
type : 'POST',
dataType : 'json'
});
}
process(
'http://www.google.co.uk',
{
param1 : 'a'
},
function(resp) {
alert('Success');
},
function() {
alert('Uh oh');
}
);
You can then pass any function to process and it will be called on success/error.