Skip to content

Instantly share code, notes, and snippets.

@dagda1
Created February 8, 2011 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagda1/816227 to your computer and use it in GitHub Desktop.
Save dagda1/816227 to your computer and use it in GitHub Desktop.
jquery 1.5 ajax
function getJSONObject(url, params, ajaxCallBack, ajaxErrorHandler, excludeProgress){
var e = (ajaxErrorHandler) ? ajaxErrorHandler : validationErrorCallBack;
var s = (ajaxCallBack) ? ajaxCallBack : jsonCallBack;
if (!excludeProgress)
$('#working').show();
$.ajax({
type: "POST",
url: url,
cache: false,
data: params,
beforeSend: function(xhr) {
xhr.setRequestHeader("Ajax", "true");
xhr.setRequestHeader("UseAjaxError", "true");
},
complete: function() {
if (!excludeProgress) {
stopWorking();
$('#working').hide();
}
},
success: s,
timeout: _ajaxTimeOut,
dataType: "text json",
jsonp: null,
jsonpCallback: null,
error: e
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment