I’m just learning how to utilise ajax/json with jquery and I’ve hit a brick wall that I just don’t understand.
Here is my code – VERY simple code:
$("#click").click(function() {
$.getJSON("http://localhost/jsontest/a.json", function(data) {
alert("done");
});
});
Basically, load a.json and send an alert to the screen saying done.
Here are the contents of a.json:
{ “done”: “37” }
That’s it.
It doesn’t work though… the alert is not displayed.
Any ideas folks?
I’m betting on this: you forgot to put that setup code in a
<script>block after your “click” element, or in a “ready” handler: