I’m trying to get the following piece of code working (the spinning gif never loads, nor is the data retrieved), but its not and I can’t seem to see the problem - any thoughts
<html>
<head>
<title> this is an ajax test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
function example_ajax_request() {
// Put an animated GIF image insight of content
$("#content").empty().html('<img src="ajax-loader.gif" />');
// Make AJAX call
$("#content").load("http://www.bbc.co.uk");
});
</script>
<head>
<body>
<p><input type="button" value="Load Content" onclick="example_ajax_request()" /></p>
<div id="content">
Please click "Load Content" button to load content.
</div>
</body>
</html>
I thought it might have been a problem with trynig to load data from an external site, so I changed the url in the load function to a local file: data.txt, which random ascii content. Trying this in Firebug, and stepping through it I can see the gif load but when it lands on the load function it says:
XMLHttpRequest cannot load file:///C:/***********/data.txt. Origin null is not allowed by Access-Control-Allow-Origin.