SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    fade in and fade out effects in ajax request

    I'm starting with ajax and I'd like to add fade in and fade out effects when new content is loading. How can I make such effect and where in this code should I put it?

    Code:
    <html>
     <head>
      <script type="text/javascript">
      <!--
       function httpRequest(pURL) {
            if (window.XMLHttpRequest) { // Mozilla
                  xmlhttp=new XMLHttpRequest();
                  xmlhttp.onreadystatechange=handleRequest;
                  xmlhttp.open("GET", pURL, true);
                  xmlhttp.send(null);
           } else if (window.ActiveXObject) { //IE
                  xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
                  if (xmlhttp) {
                         xmlhttp.onreadystatechange=handleRequest;
                         xmlhttp.open('GET', pURL, true);
                         xmlhttp.send();
                  }
           }
      }
     
      function handleRequest() {
           if (xmlhttp.readyState==4) {
                  if (xmlhttp.status==200) {
                         document.getElementById('mydiv').innerHTML=xmlhttp.responseText;
                  }
           }
      }
      //-->
      </script>
    </head>
     
    <body>
      <div id="mydiv"></div>
      <br><a href="javascript:httpRequest('/test.html');">Open test.html</a>
    </body>
    </html>

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you looked at jQuery for your ajax and "fade" requirements?
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I know I can use some effects from some framework but i'm not sure in which place of my script I should put them to work properly


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
  •