Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What is the Difference between failure and err message in JavaScript(JQuery)?

user-image
Question ajoutée par Zaheer Ahmad , Software Developer(Asp.net) , Scaleable Solution(Pvt) Islamabad
Date de publication: 2015/08/10
Alaa Jaddou
par Alaa Jaddou , Exicutive Manager , Site Trip

The two options are equivalent.

However, the promise-style interface (.fail() and .done()) allow you to separate the code creating the request from the code handling the response.

You can write a function that sends an AJAX request and returns the jqXHR object, and then call that function elsewhere and add a handler.

When combined with the .pipe() function, the promise-style interface can also help reduce nesting when making multiple AJAX calls:

$.ajax(...)

 

.pipe(function(){

return $.ajax(...);

})

.pipe(function(){

return $.ajax(...);

})

.pipe(function(){

return $.ajax(...);

});

More Questions Like This