SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Location
    North Carolina
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Ajax with div not being populated

    Hey guys,

    Have an easy one for you I am sure. But to put it simply, first go to http://www.inspiredmind.net/dev/ajax.html

    View the source and please tell me why the div with the id contents is not being populated when you click the link. The alert is working (obviously). Any help is appreciated.

    Just trying to get a better understanding of httprequest and simple javascript/dom.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.getElementById("contents").value = http_request.responseText;

    should be

    document.getElementById("contents").innerHTML = http_request.responseText;

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Location
    North Carolina
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And what is the reasoning for this? I always thought it was .value and I know I've seen it before (hence why I was using it..) But yeah, that definitely worked. Thanks.

    But like I said, could you distinguish the different in .innerHTML and .value when I should use one over the other? Or if not at all. Or am I thinking of the syntax needed for like input's, etc?

  4. #4
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .value is only relevant for form elements like textboxes, etc. - .innerHTML is used for any container element.


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
  •