0

I've got a sample script as below. I wanna see if local.js or online/latest.js failed to load. Is it possible?

<html>
<title>My JQuery Test</title>
<head>
    <!--<script type="text/javascript" src="jquery/jquery.local.js"></script>-->
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("#Buttons-theTestAlert").click(function () {
                alert("`Test Alert` clicked");
            });
        });
    </script>
</head>
<body>
    <button id="Buttons-theTestAlert">Test Alert</button>
</body>
</html>
Nam G VU
  • 33,193
  • 69
  • 233
  • 372

1 Answers1

2

You can test

if (myFunction) myFunction()
else alert('not loaded (yet)')
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • That's brilliant and works for my own script. Though, we can't apply this to other owners' scripts e.g. jquery script :) Do u have any workaround for it? – Nam G VU May 20 '11 at 14:25
  • 1
    Why could you not do this for other scripts??? http://stackoverflow.com/questions/1828237/check-if-jquery-has-been-loaded-then-load-it-if-false – mplungjan May 21 '11 at 05:12