Vote count: 0
Say you execute an ajax request upon a change event like so:
MyClass.prototype.bindChangeEvent = function(){
$(document).on('change', '#elementid', function(){
var $element = $(this);
$.ajax({
url: '/someurl'
});
});
}
Now, in client code, How can you attach to that ajax promise the done/fail/always callbacks?
You can't return the promise from the ajax request because its only created on the change event.
Is there a way to create a promise ahead of time and tell jQuery to use that promise for a particular ajax request?
asked 34 secs ago
Using promises with ajax in change events
Aucun commentaire:
Enregistrer un commentaire