Skip to content
Advertisement

How to stop jQuery .ajax() execution when success is false?

I have this code which works.

JavaScript

However I have some more code after that like:

JavaScript

However, I need to stop the script when success:function(data) is false.

So, I thought that return false; should stop the execution

JavaScript

, however it is not working and the code after $.ajax is executed anyway.

How to stop the script when the success is false?

Any advice? Thanks in advance.

ADDITIONAL INFO: I have another ajax call which I want to execute when success is true:

JavaScript

How to execute this code only after success of the first ajax call?

Advertisement

Answer

Your extra code should be in the callback itself.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement