Loading ...
Sorry, an error occurred while loading the content.

Re: [OLmws] Ajax calls always show old data

Expand Messages
  • Foteos Macrides
    Adam, The second argument for OLgetAJAX must be a function reference, meaning the name of a function without parens. Thus, if you want to pass a CAPTION
    Message 1 of 3 , Feb 5, 2007
    View Source
    • 0 Attachment
      Adam,
       
      The second argument for OLgetAJAX must be a function reference, meaning the name of a function without parens.  Thus, if you want to pass a CAPTION parameter to the function, do that as a global variable rather than as an argument for the function.  So in your overlibphorum.js change what you presently have to:
       
      var thisCaption=' ';
       
      function lastPostPreview(){
       return overlib(OLresponseAJAX,
        TEXTPADDING,0, CAPTIONPADDING,4,
        CAPTION,thisCaption,
        WRAP, BORDER,2, STICKY, SCROLL,
        MIDX,0, RELY,100);
      }
       
      and when making calls use:
       
      onmouseover="thisCaption='blah blah blah';
        return OLgetAJAX('http://etc.',
        lastPostPreview, 300, 'lastPostPopup');"
       
      Note that for OLpageDefaults you can use the desired commands and parameters as a comma-separated list of arguments in one OLpageDefaults call, rather than broken up into a series of OLpageDefaults calls as you are doing in overlibphorum.js.
       
      Fote
      --
       
      ----- Original Message -----
      Sent: Monday, February 05, 2007 12:37 AM
      Subject: [OLmws] Ajax calls always show old data

      Hi, I'm a new user of OverlibMWS, so first of all thank you to the developers for maintaining the project.

      I have been playing with the Ajax examples, and have a strange problem.  I have multiple popups on one page, and the first time one is activated, the Ajax call always fails (the caption shows as it is not reliant on Ajax, but the server-side text does not load).  If I then activate a *different* popup, the data from the first one shows.  This continues, so the popup always shows the data from a previous mouseover. ie: it is always "one behind".

      Has anybody encountered something like this before?

      You can see an example of what I mean by going to:
      http://www.cantonese.sheik.co.uk/phorum/list.php?3
      ..and hovering over any of the "last post" links.  It's a little confusing, as the caption (non Ajax) will always be
      correct, but the message that shows is always wrong for me (unless I hover over the same link twice, then it is correct :-)  )  I thought it might be a caching problem with my network provider, but if I hit my server side script directly it always serves the correct data.  I also thought it might be a browser caching issue, but I see the same behaviour in Firefox and IE7.

      I've hopefully overlooked something obvious, but examining my page source shows that the message IDs I am including in the Overlib Ajax calls are correct.

      So, any idea why my popups are showing this unfortunate behaviour?

      Many thanks,

      /\dam
    • adam.sheik
      Many thanks for your reply, ... Thank you, I have now changed my code to use a global thisCaption variable rather than passing it as a parameter. In order to
      Message 2 of 3 , Feb 5, 2007
      View Source
      • 0 Attachment
        Many thanks for your reply,

        > The second argument for OLgetAJAX must be a function reference,
        >meaning the name of a function without parens. [...]

        Thank you, I have now changed my code to use a global "thisCaption"
        variable rather than passing it as a parameter.
        In order to get my (incorrect) parentheses to work I had to modify
        line 119 of ajaxcontentmws.js - but I have now put this back to the
        original official code :-)

        Unfortunately, even though I am now running code as close as possible
        to the official examples, my Ajax call still fails for the first
        mouseover.
        I've checked my Apache weblogs, and it is calling my server script
        with the correct arguments, and there are no "double requests" like
        have been reported in another thread on this group.
        Could it be possible that the correct data is being sent to Overlib,
        but not in time for it to display, so it shows the old data the next
        time it is called?
        If we can work out why the first call on the page fails, then that
        will probably be the key to the puzzle...

        > Note that for OLpageDefaults you can use the desired
        >commands and parameters as a comma-separated list of
        >arguments in one OLpageDefaults call, rather than broken
        >up into a series of OLpageDefaults calls as you are doing in
        >overlibphorum.js.
        Yes, but as a newbie, I found the long way easier to read :-)

        /\dam
      • adam.sheik
        I now have it working! Sticking with my theory that the delay in talking to the server could be at fault, I modified the ALTERNATIVE FORMAT example at
        Message 3 of 3 , Feb 5, 2007
        View Source
        • 0 Attachment
          I now have it working!
          Sticking with my theory that the delay in talking to the server could
          be at fault, I modified the ALTERNATIVE FORMAT example at
          http://www.macridesweb.com/oltest/AJAX.html - this calls Overlib
          normally with a "Loading..." message and makes the Ajax call after the
          window displays. This seems to work perfectly!

          I am temporarily leaving my previous code in place on my live site at:
          http://www.cantonese.sheik.co.uk/phorum/list.php?7

          You can see the new call by hovering over any "last post" link.
          You can see the code which shows old data by mhovering over any
          asterisk to the right of the "last post" links.

          I'm curious to hear any theories why the original basic call didn't
          work for me.

          By the way, there is a code typo at
          http://www.macridesweb.com/oltest/AJAX.html
          Underneath the red text reading AN ALTERNATIVE FORMAT, there is a
          missing comma in the code block before "WRAP". This took me a while to
          debug! :-)

          /\dam
        Your message has been successfully submitted and would be delivered to recipients shortly.