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>

1 Answer 1

2

You can test

if (myFunction) myFunction()
else alert('not loaded (yet)')
2
  • 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
    Commented May 20, 2011 at 14:25
  • 1
    Why could you not do this for other scripts??? stackoverflow.com/questions/1828237/…
    – mplungjan
    Commented May 21, 2011 at 5:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.