SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ajax update content

    i downlaoded this script and done nothing to it and it dosnt seem to work it just sits on loading content does anyone know whats wrong or can post a code that works:

    Code:
    http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-content
    Animated Chatrooms - www.121chatrooms.net

  2. #2
    SitePoint Member
    Join Date
    May 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mike4x4s View Post
    i downlaoded this script and done nothing to it and it dosnt seem to work it just sits on loading content does anyone know whats wrong or can post a code that works:

    Code:
    http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-content
    Mike, how are you running the script? Did you just download it and open up the html file in your browser? If so, that could be your problem was the XHR command will fail. If you don't have FireBug installed, install it and see what the XHR call is doing.

    Rey

  3. #3
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i dont have firebug please test it at http://220.245.192.227/test/ajax
    Animated Chatrooms - www.121chatrooms.net

  4. #4
    SitePoint Member
    Join Date
    May 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike your link doesn't work.

  5. #5
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pklz try now the website loads in firefox
    Last edited by Mike4x4s; Apr 13, 2008 at 00:46.
    Animated Chatrooms - www.121chatrooms.net

  6. #6
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have this new code that is ajax and refreshes the page every few seconds but still has a flicker in ie the url to this is http://220.245.192.227/test/ticker

    code:
    index.php
    Code:
    <head>
    <script type="text/javascript">
    var page = "test2.php";
    function ajax(url,target)
     {
        // native XMLHttpRequest object
       document.getElementById(target).innerHTML = '';
       if (window.XMLHttpRequest) {
           req = new XMLHttpRequest();
           req.onreadystatechange = function() {ajaxDone(target);};
           req.open("GET", url+"?sid="+Math.random(), true);
           req.send(null);
       // IE/Windows ActiveX version
       } else if (window.ActiveXObject) {
           req = new ActiveXObject("Microsoft.XMLHTTP");
           if (req) {
               req.onreadystatechange = function() {ajaxDone(target);};
               req.open("GET", url+"?sid="+Math.random(), true);
               req.send();
           }
       }
             setTimeout("ajax(page,'scriptoutput')", 2000);
    }
    
    function ajaxDone(target) {
       // only if req is "loaded"
       if (req.readyState == 4) {
           // only if "OK"
           if (req.status == 200 || req.status == 304) {
               results = req.responseText;
               document.getElementById(target).innerHTML = results;
           } else {
               document.getElementById(target).innerHTML="ajax error:\n" +
                   req.statusText;
           }
       }
    }
    </script>
    </head>
    <body onload="ajax(page,'scriptoutput')">
    <span id="scriptoutput"></span></p>
    </body>
    Animated Chatrooms - www.121chatrooms.net

  7. #7
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i really want it to refresh the page automaticalyl with no flicker effect when the text is updated inside the text file store/mike.txt is it possible?
    Animated Chatrooms - www.121chatrooms.net

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,713
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    No, it is not possible to refresh the IE page without the flicker. Their browser isn't made to work that way.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so are you saying with ajax always images will flicker? no matter what and there is no way around it
    Animated Chatrooms - www.121chatrooms.net

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,713
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    When using proper ajax techniques that's not an issue.
    If the page is flickering then something else may be going on.
    I shall bow now to ajax experts who may come along.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •