Thread: XHTML and AJAX

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0

    XHTML and AJAX



    Hi everyone,
    Does anybody knows if it is posible to use AJAX for updating a XHTML
    page?

    Thank you,
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,066
    Rep Power
    1990
    Yes, it's exactly the same as updating a HTML page.

    The only (real) difference between HTML and XHTML is that XHTML needs all of the tags closed properly, like in XML where HTML can be a bit looser if developers "forget" or get a bit lazy.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0

    still not working


    yes, but for the connection to document we had:
    xhr.onreadystatechange = function(){
    if(xhr.readyState == 4){
    document.getElementById("target").
    green Code:
    innerHTML
    =xhr.responseText;
    }
    }

    which we cannot change inner HTML to inner XHTML, AJAX doesnt accept that,
    so any other alternative for AJAX connection to XHTML?
    cheers,
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    What type of element is "target"?
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0
    it`s <div id="target"></div>
    so usually after server side process, the results will be shown in target
    (in html),but it`s not working for xhtml
    tnx
  10. #6
  11. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    innerHTML is not a standard.
    JavaScript Code:
    document.getElementById("target").appendChild(xhr.responseText);
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    246
    use JQuery, it's simpler...

    Code:
    document.getElementById("target").appendChild(xhr.responseText);
    becomes
    Code:
    $('#target').html(xhr.responseText);
    But remember to load the JQuery framework first!
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  14. #8
  15. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    Originally Posted by 1DMF
    use JQuery, it's simpler...
    Why would someone want to use a large framework to perform a single reference call and variable assignment?
    Frameworks can be useful if you are going to write, or use, a large project. Using it for trivial scripts is not only lazy but it will not help the op understand the fundamentals of the language.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  16. #9
  17. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    246
    The JQuery framework is a lightweight 92KB* (*version 1.7.1) JS file , that automates a whole host of processes.

    If the only thing they wish to do on their entire website is this single operation then fair play roll your own.

    If not, give it a whirl , it will change your aproach to JS and the way you implement client side functionality for the better and the benefit of your users!

    Plus it makes JS coding quicker and easier.

    But of course that's just my opinion, you should always make your own mind up!
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0
    to be honest, non of the above worked, I reckon that inneHTML is standard for AJAX
  20. #11
  21. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Location
    Jakarta, Indonesia.
    Posts
    184
    Rep Power
    31
    innerHTML has been the BLACKBOX of javascript for a long time You put a text in there, and you'll get an instant (X)HTML object/ element as the output. However, giving it a "bad" input would give you an unpredictable result.

    Maybe you should first forget this <div> for a second and use other elements instead like <input> or <textarea>. Just paste the xhr.responseText into the value attribute of either of these elements; see whether the response from xhr is always well-formatted as a XHTML element? If it is then you're ready to use <div>'s innerHTML.
    Last edited by hdewantara; July 29th, 2012 at 12:14 AM.
  22. #12
  23. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    Originally Posted by Pouya
    to be honest, non of the above worked, I reckon that inneHTML is standard for AJAX
    innerHTML is not part of the standard DOM, it is an implementation by the browsers.

    As hdewantara mentioned, this is most likely a problem with the string that is being returned from the server-side.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  24. #13
  25. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    Originally Posted by 1DMF
    The JQuery framework is a lightweight 92KB* (*version 1.7.1) JS file , that automates a whole host of processes.

    If the only thing they wish to do on their entire website is this single operation then fair play roll your own.

    If not, give it a whirl , it will change your aproach to JS and the way you implement client side functionality for the better and the benefit of your users!

    Plus it makes JS coding quicker and easier.

    But of course that's just my opinion, you should always make your own mind up!
    You sound like someone trying to sell jQuery. jQuery is a framework of an existing language, nothing more, it adds no more functionality to the language than already exists. If you advise a user to learn jQuery from the get-go, they will never gain an understanding of the actual language nor will they be able to deal with issues under-the-hood of the framework.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  26. #14
  27. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    246
    You sound like someone trying to sell jQuery.
    Really?

    It's up to you what you do and who you listen to Pouya, just remember JQuery is FREE
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0
    I dont reckon, coz as I said, the same come workes with HTML, with the same php, same AJAX!!
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo