SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict trican's Avatar
    Join Date
    Sep 2003
    Location
    someplace
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery Load question

    Hi all,

    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

    Code:
    <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>
    thanks!
    Free Image Editing Webapp, includes
    easy to use creative transformations to
    enrich your digital photographs @www.PureRGB.com

  2. #2
    SitePoint Addict trican's Avatar
    Join Date
    Sep 2003
    Location
    someplace
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:

    Code:
    XMLHttpRequest cannot load file:///C:/***********/data.txt. Origin null is not allowed by Access-Control-Allow-Origin.
    Any thoughts?
    Free Image Editing Webapp, includes
    easy to use creative transformations to
    enrich your digital photographs @www.PureRGB.com

  3. #3
    SitePoint Addict trican's Avatar
    Join Date
    Sep 2003
    Location
    someplace
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like it is in fact working ok in Firefox but not in Chrome. I suspect when I upload this html file to my server it'll function ok in Chrome too.

    Just in case anyone is wondering this is my final code:
    Code:
    <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("data.txt");
    };
    </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>
    Free Image Editing Webapp, includes
    easy to use creative transformations to
    enrich your digital photographs @www.PureRGB.com

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2011
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sometimes if something isn't showing in chrome it just needs a couple of 'CTRL+F5's' (clears cache for that page)

    Chrome seems to have a very persistent cache (what makes it fast I guess). sometimes one CTRL+F5 won't do it so I just hit it 4 or 5 times everytime.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •