SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot Zurev's Avatar
    Join Date
    Feb 2009
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Minor AJAX Question

    Alright well my website has very little desire for ajax, I have a front page with 10 article listings. I use ajax currently to check the database for any new articles and then it reloads the div, that is pretty much the extent of my need. However I would like to put one final touch on it, that being that the div fades in...
    Code:
    xmlHttp.onreadystatechange=function(){
    	if(xmlHttp.readyState==4){
    		document.getElementById('articles').innerHTML=xmlHttp.responseText;
    		setTimeout('Ajax()',5000);
    	}
    }
    xmlHttp.open("GET","http://localhost/articlefeed",true);
    So I was curious as to how to get that working, preferably without dabbling into jQuery, but I will if I absolutely have to.

    Thanks.

  2. #2
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hate to give a lazy answer but seeing as no-one else answered, jquery (as you probably know) is going to really optimize this whole process and make the ajax request and animation a piece of cake.

    I appreciate that its beneficial to know how to do it without jquery, but unless you have a compelling reason, I would stick with the easier road.
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  3. #3
    Barefoot on the Moon! silver trophy
    Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,516
    Mentioned
    51 Post(s)
    Tagged
    1 Thread(s)
    I'll have to echo wheeler on this. A javascript framework (such as jQuery) will take care of a lot of the browser inconsistencies and actually prove to be easier than trying to write everything by hand.

    http://docs.jquery.com/Tutorials
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


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
  •