Advanced Search

Results 1 to 6 of 6

Thread: content will not load on web server but will load on local server

  1. #1
    Join Date
    Dec 2008
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default content will not load on web server but will load on local server

    Hi all,

    I have a site with Ajax content that is dynamically loaded. I store the product to be loaded on the URL using a #product_id=xxx. The page then uses a window.onload function to call a Ajax function to load the neccessary info about the product.

    The problem I have now is this.
    1. If I click on a link that links to that page .. eg. product.php#product_id=1 ... It works

    2. However, if I refresh or manually type in the URL .. it does not work.

    3. This problem is present in chrome and firefox but surprisingly not in IE6.

    BUT, when I was developing the page on my localhost server. It works. I was developing using a apache server as well as MAMP on a mac. They both work.

    Any reason that the content will load on a local server but not on a remote server ? btw ... my hosting compay is bluehost.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Can you post a link? There could be a lot of reasons.

    The general reason here is likely something related to the security issues associated with ajax, but beyond that it's hard to guess. I'm not particularly experienced with this sort of problem, but others here will probably know better. Either way, it'll help to see the site to figure out what's wrong.

    In general, relative paths will be best for ajax due to security restrictions. See if that helps. That's my only guess at this point.
    And if you've changed any of the URLs to external sites, that may also be the problem. But if you haven't changed your code, then that's not relevant.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2008
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    All pages loaded are not from external site. Everything loaded is from the same server.

    The site is at http://www.themagictouch.com.sg/touc...gift_products/

    If you load that page the first time ... everything will load. But when you hit refresh, the content will not load.

    Is there a difference between a link to a page and a refresh of the page ?

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    You have an error


    ajaxpage(Object { name="url"}, Object { name="containerid"}, Object { name="hash"})ajaxcontent.js (line 36)
    CheckForHash()ajax_history.js (line 24)
    ajax_history.js()ajax_history.js (line 35)
    [Break on this error] document.getElementById(containerid).i...v>" //Display "fetching page message"
    ajaxcontent.js (line 36)

    Not sure if that will resolve it or not.
    Corrections to my coding/thoughts welcome.

  5. #5
    Join Date
    Dec 2008
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Wierd ...

    The line of code that seems to be in question is

    document.getElementById(containerid).innerHTML="<div align=center><br><img src='../common/images/loading.gif'><p>Requesting content, please wait...</p></div>"; //Display "fetching page message"

    This is just the html content to load to show the spinning wheel when the ajax content is loading...

    From what I can see ...
    The problem seems to be that when I refresh the page ... the javascript variable call current_hash is not being cleared.

    At the top of my page, I declare

    <script type='text/javascript'>var current_hash = "";</script>

    then when the page loads, I check if the current_has has changed

    function CheckForHash(){
    if(document.location.hash){
    var HashLocationName = document.location.hash;
    HashLocationName = HashLocationName.replace("#","");

    if (HashLocationName != current_hash){
    current_hash = HashLocationName;

    switch(current_hash)
    {
    case "print1":
    url = "heat_transfer.php";
    break;
    case "print2":
    url = "silkscreen.php";
    break;
    case "print3":
    url = "embroidery.php";
    break;
    default:
    url = "inline_view.php?" + HashLocationName;
    }
    ajaxpage(url, 'inline_view',document.location.hash)
    }
    }
    else
    {
    ajaxpage('inline_view.php', 'inline_view','#0')
    }
    }

    var HashCheckInterval = setInterval("CheckForHash()", 500);
    window.onload = CheckForHash;

    So by right when I refresh a page, the current_hash var should be cleared back to blank and the relevant ajax content should load in based on the hash set in the URL.

  6. #6
    Join Date
    Dec 2008
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi All,

    Still can't solve this issue. Now I have some new findings.

    As the same as last time.

    First time loading the page -> Ajax content loads properly.
    Hit refresh ... Page loads but Ajax content does not load.
    When I am running it on a localhost ( I have tried both MAMP on a mac and Apache on windows) It works perfectly !!

    Now I used firebug to try and find the problem. I insert a breakpoint and slowly stepped through the code and guess what ? The Ajax content loaded !! So I can't find the bug !!

    When I just hit refresh with no breakpoint, I get the message on the chrome javascript console

    "Uncaught TypeError: Cannot set property 'innerHTML' of null"

    The Line of code that is giving the error is

    document.getElementById(containerid).innerHTML="<div align=center><br><img src='../common/images/loading.gif'><p>Requesting content, please wait ... </p></div>"

    I really don't see how null could ever come up in this line of code ??

    Could anyone help ?

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
  •