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>
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: