Ajax - How to Print <p> or Other HTML Elements Insted of Form Text Boxes?

Discussion in 'JavaScript' started by webgaya, Jul 1, 2007.

  1. #1
    In all Ajax tutorials I found, the server response is
    printed on a form text box as below,

    document.formName.textBoxName.value = ajaxRequest.responseText;

    But my server response is not just a piece of text.
    It contains few paragraphs and a form. How can I print
    them right below where the Ajax was called?

    For an example I want to print following set of HTML,

    <p>first paragraph</p>

    <form name="myForm">
    <input type="text" name="fName">
    <input type="button" name="submit" value="Submit">
    </form>

    <p>second paragraph</p>
     
    webgaya, Jul 1, 2007 IP
  2. PDoc

    PDoc Peon

    Messages:
    47
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check out
    document.write()
    PHP:
    If you have the paragraphs and everything in

    ajaxRequest.responseText
    PHP:
    you can output all that with

    
    document.write(ajaxRequest.responseText);
    
    PHP:
     
    PDoc, Jul 1, 2007 IP
  3. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #3
    or element.innerHTML = ajaxObject.responseText;
     
    gibex, Jul 1, 2007 IP