I'm using $.ajax to get some HTML from the server.
my javascript makes use of promises and I want to avoid creating another promise and use jQuery ajax since it's already a promise.
But is there some way I can reject the promise inside the "done" callback?
my code looks something like this:
function get_html(){
return $.ajax({ .... }).done(function(response){
if(response.haveErrors){
// here how do I reject and return the promise?
return;
}
// code #2 should run normally
// but can i pass a "parameter" to done() ?
}).fail(function(){
....
});
}
and the usage:
get_html().done(function(parameter){
// code #2
}).fail(function(){
});
Also, is it possible to pass a parameter to code # 2? in the done callback?