Call complete() within Success()

Asked

Viewed 37 times

0

Consider my code ajax below

function update(){
   $.ajax({
       url  : 'my.hrl',
       type : 'get',
       dataType : 'json',
       success : funcion(data){

           if(data.id == null){
               //chamar. complete ou error
            }

        },
       complete : function(){ 
          setInterval()
       }
   });
}

There is a way for me to call the complete or error, inside the Success, if some value does not come the way I want null or Undefined type?

[EDIT 1] Was that I would like to update the function only again when the request was completed after 3 seconds.

If the value of this null would also only try after 3 seconds

  • Complete will run only after Success runs. That’s what you want it to be. You could create a function that you can call in the complete and Success. Maybe if you go into more detail your problem will be better for you to answer.

  • 1

    Just one observation, the success and error are obsolete and have been replaced by done and fail in newer versions of Jquery

  • 1

    you can abstract to another function and call this same function within the other 3

  • Create a function outside and call within the two methods!

  • Type php that in Try catch if not fall inside the Try I can give a throw new to go to the catch

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.