I have a custom wrapper function around jquery ajax.
custom.get = function (path, callback) {
// do other things
$.get(path, function () {
callback()
})
}
doing
$.when(custom.get(path), custom.get(path)).done(function (result1, result2) { callback})
doesn’t seem to work. Is it supposed to work? Any alternatives for doing defers?
You need to return the
jXHRobject (which abstracts a jQueryDeferred) from yourcustom.get()function in order to make this work:You should also check if your second parameter passed in, really is a function to avoid unnecessary errors, see above.