Agile Development Practices suggest developers keep a solutions log. I think we can all benefit from a combined solutions log. As I encounter errors or problems I intend to record the solutions on this blog. Please feel to leave your comments, solutions and email me with your errors and solutions.
Apr 4, 2013
Javascript AJAX Wrapper
AJAX Wrapper
var AJAXWrapper = {
getData: function (ajaxObject) {
var dfr = $.Deferred();
ajaxObject.success = dfr.resolve;
$.ajax(ajaxObject).error(function () {
alert('Error with AJAX request');
});
return dfr.promise();
}
};
Usage
var ajaxObject = {
url: "/path/to/data.html",
data: { email: "my@email.com" },
dataType: 'html'
};
AJAXWrapper.getData(ajaxObject).then(function (data) {
console.log(data);
});
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment