Reputation: 7277
the following works in Chrome, Firefox, Opera and Safari, but of course not in MSIE 8 or MSIE 8-compatibility view:
<html>
<head><title>saffds</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript"> alert($);
</script>
</head>
<body>afdskakj</body></html>
MSIE claims that $ is undefined, whereas the other browsers display the $-function of jQuery.
I have tried deleting all temporary files and restarting MSIE, setting the internet options > security > local internet to "very low" but it does not help.
Jquery from ajax.googleapis.com used to work for me a few days ago, but now I have no idea what changed to break this.
What causes this to fail?
Thanks,
-- Edit: I have tested the following, which also does not work except for Link1 which does not depend on jQuery and otherfile.js' alert which also does not depend on jQuery.
<html>
<head><title>saffds</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="otherfile.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert('I love jQuery!');
});
</script>
</head>
<body>afdskakj
<a href="" onclick="alert('Hello world')">Link1</a>
<a href="">Link2</a>
<script type="text/javascript">
$(document).ready(function() {
alert('I love jQuery!');
});
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
</script>
</body></html>
the contents of otherfile.js is simply:
alert("otherfile");
Upvotes: 3
Views: 276
Reputation: 7277
My problem was resolved by resetting MSIE as described here:
http://support.microsoft.com/kb/318378
Upvotes: 2
Reputation: 2211
It looks like your jQuery file is not downloaded yet. Check the chapter "hello jquery" in this tutorial.
You need to have to wait till everything is ready:
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
Upvotes: 0