Link to home
Start Free TrialLog in
Avatar of Steve Tinsley
Steve TinsleyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Make Uncaught TypeError not stop Javascript

I have a script which is polling for new data every 10seconds and doing things with the data.
Is there a way that if the browsers incurs an Uncaught TypeError - that the polling just tries again rather than stopping the js?
Avatar of Leonidas Dosas
Leonidas Dosas
Flag of Greece image

Try with an if statement like this:
if((typeof data) === "undefined"){
//code here
}

Open in new window

What is causing the error - maybe you should be addressing that.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Tinsley

ASKER

What I was hoping for was a quick fix globally.... I know it's not good practice, but I havent got time to get it fully tested right now and I dont want the system to stop working.
What I was hoping for was a quick fix globally.... I know it's not good practice, but I havent got time to get it fully tested right now and I dont want the system to stop working.

I well understood that, that's why my code is global and over your ajax code,