troubleshooting Question

try catch not working with $().load();

Avatar of waffe
waffeFlag for United States of America asked on
JavaScriptPHPjQuery
2 Comments1 Solution271 ViewsLast Modified:
Hi,

I am using a simple try catch in JavaScript but the catch is never working even if the .load is pointed to a file that is not there. In the code below the second alert never happens even if I point the first .load() to nothing.
<script>
setInterval(function() {
    try{
		$("#slogan_rotate_txt").load("ans.php","");
		alert ("try1");
	} catch(err) {
		$("#slogan_rotate_txt").load("../mod/my1_theme/views/default/my1_pages/slogans.php","");
		alert ("try2");
	} 
}, 5000);
</script>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros