Skip to content

Commit

Permalink
Returning false in 'start' doesn't cause TypeError
Browse files Browse the repository at this point in the history
TypeError: $.ajax($.extend({
	beforeSend: function (xhr) {
		return inner.fire({
			name: "start",
			off: settings.off || {}
		}, xhr);
	}
}, settings)).done is not a function...

fix
  • Loading branch information
vojtech-dobes committed Sep 14, 2012
1 parent 1fea31e commit 44d1fe2
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions nette.ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var nette = function () {
*/
this.ajax = function (settings, ui, e) {
if (!settings.nette && ui && e) {
var $el = $(ui);
var $el = $(ui), xhr;
var analyze = settings.nette = {
ui: ui,
el: $el,
Expand Down Expand Up @@ -183,29 +183,33 @@ var nette = function () {
off: settings.off || {}
}, settings, ui, e)) return;

return $.ajax($.extend({
xhr = $.ajax($.extend({
beforeSend: function (xhr) {
return inner.fire({
name: 'start',
off: settings.off || {}
}, xhr);
}
}, settings)).done(function (payload) {
inner.fire({
name: 'success',
off: settings.off || {}
}, payload);
}).fail(function (xhr, status, error) {
inner.fire({
name :'error',
off: settings.off || {}
}, xhr, status, error);
}).always(function () {
inner.fire({
name: 'complete',
off: settings.off || {}
}, settings));
if (xhr) {
xhr.done(function (payload) {
inner.fire({
name: 'success',
off: settings.off || {}
}, payload);
}).fail(function (xhr, status, error) {
inner.fire({
name :'error',
off: settings.off || {}
}, xhr, status, error);
}).always(function () {
inner.fire({
name: 'complete',
off: settings.off || {}
});
});
});
}
return xhr;
};
};

Expand Down

0 comments on commit 44d1fe2

Please sign in to comment.