Thread: XHTML and AJAX

Page 2 of 2 First 12
  • Jump to page:
    #16
  1. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,131
    Rep Power
    4304
    jQuery is great, but it is a certain amount of overhead and it's best to have a solid understanding of plain JavaScript and DOM before using it.

    Originally Posted by Pouya
    Does anybody knows if it is posible to use AJAX for updating a XHTML
    page?
    Are you using real XHTML? What is the content-type HTTP response header set to? If it's set to "text/html", then you're using HTML with XHTML syntax, which is not really XHTML.

    Anyway, you could be using responseXML, instead of responseText, then you can use importNode. However, IE versions before 9 didn't implement it, so you'll need to use a workaround to support them.
    http://reference.sitepoint.com/javas...ent/importNode
    https://developer.mozilla.org/en/DOM...ent.importNode
    http://www.alistapart.com/articles/c...wserscripting/

    Originally Posted by Winters
    JavaScript Code:
    document.getElementById("target").appendChild(xhr.responseText);
    It's been a while, but I seem to remember that you can't append a string directly to an element like that. You need to use document.createTextNode() first.

    Comments on this post

    • Winters agrees : My mistake.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  2. #17
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    As Kravvitz says.
    JavaScript Code:
    document.getElementById("target").appendChild(document.createTextNode(xhr.responseText));
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo