0

In a page that I work with, we load content from an external server from a provided dynamically created javascript file.

In one of the sections of the document that displays header content, we have the sample line:

<script type="text/javascript" src="externalScriptLocation"></script>

The problem is that when the external script location is down (it could be a 404, but in this case it's actually a 503 - service not available), most of the page's functionality appears to work but the page is not able to properly submit data.

Is there a way I can wrap this with a try/catch or something similar so that failure to load this bit of javascript (which is for a header element that, while it should be there, shouldn't cause these issues!) so that the site can function normally?

If it matters, the server side language is Java with Java Server Pages as the view.

MetroidFan2002
  • 29,217
  • 16
  • 62
  • 80
  • Does this have to be done in javascript? What server side language are you using? – Elliot Fehr Apr 21 '14 at 16:12
  • Added that detail to the question for you. Not sure that it matters, though, the external server isn't under our control and the content is purely a javascript snippet, so I believe it has to be done in Javascript. – MetroidFan2002 Apr 21 '14 at 16:28
  • This should be helpful: http://stackoverflow.com/questions/538745/how-to-tell-if-a-script-tag-failed-to-load. – KJ Price Apr 21 '14 at 16:34

0 Answers0