Reputation: 1
Why does it not print "Hello" in my browser?
I have this code in a file called index.html
<!DOCTYPE html>
<html>
<head>
<title>Learning Ajax</title>
</head>
<body>
<h1>Learning Ajax</h1>
<a href="files/ajax.txt">Load Ajax Text File</a>
<script src="js/main.js"></script>
</body>
</html>
and also this code in a file called main.js
var message = "Hello";
$(function() {
var message = "Goodbye";
})();
alert(message);
its a self invoking anonymous function
Upvotes: -1
Views: 51
Reputation: 5192
There's no AJAX in the code above. I recommend visiting jQuery's learning website and finding out what AJAX is all about and how it works: http://learn.jquery.com/ajax/.
Upvotes: 0
Reputation: 30463
Because of error: you use $
, but there is no such function you have defined.
Upvotes: 2