I would like to know if there is a better approach to creating a reusable ajax object for jquery.
This is my incomplete code.
var sender = { function ajax(url, type, dataType, callback) { $.ajax({ url: url, type: type, dataType: dataType, beforeSend: function() { onStartAjax(); }, error: function(XMLHttpRequest, textStatus, errorThrown) { callback.failure(XMLHttpRequest, textStatus, errorThrown); }, success: function(data, textStatus) { callback.success(data, textStatus); }, complete: function (XMLHttpRequest, textStatus) { onEndAjax(); } }); }, function onStartAjax() {
javascript jquery design-patterns
Eeyore
source share