I have this mark up and a json.txt file which lies on the same directory as this .im unable to fetch it contents..also im not getting any errors in my firebug
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script>
$(document).ready(function(){
$.get('/json.txt',
function(data) {
$('div.result').html(data);
});
});
</script>
</head>
<body>
<div class="result"></div>
</body>
</html>
“on the same page” ? Do you mean “in the same directory” ? If so use
If this doesn’t work, I suggest using the long form to see what happens :
So you can see in your console (ctrl+maj+i) the error (or the data).
Another note : this can’t work if you’re opening the html file in
file://as the json would be considered coming from another domain. You must have an http server and open it inhttp://.