Updated Question:
JQuery animation repeats over and over if it encounters an error. Having a return or return false doesn't stop the animation from repeating. What would be the best practice to fix this error? Thanks.
<div id="label"> FADE OUT </div> <script type="text/javascript"> $(function() { $("#label") .animate( {opacity: 0}, 1000, function() { throw new Error("Some error!"); } ); }); </script>
Original Question:
Not sure why this is but after using jQuery for sometime (actually before it became mainstream) I still don't understand why certain functions will keep repeating when it encounters an error.
Example: - Make an ajax call and if the callback encounters an error the ajax call will keep calling the callback. This results in hundreds of errors in the firebug console.
- Even if you use .trigger(event) if the event you trigger has code that encounters an error jQuery keeps triggering the event over & over.
*I've tried using a try-catch and having a return, or even return false ... but it still doesn't stop jQuery from repeating the event over and over.
My question is 1.) How to stop it? and 2.) I'm very curious as to why this is happening if any one knows.
Thanks!