How Do I Submit A Form Or A Part Of A Form Without A Page Refresh

How Do I Submit A Form Or A Part Of A Form Without A Page Refresh


  • 12 Feb, 2012

    When creating a form make sure that the "form" element "onSubmit" attribute is set to a JavaScript function that returns false.
    <form onSubmit="doAJAXSubmit();return false;" >
    <input type="text" id="tf1" />
    <input type="submit" id="submit1" value="Update"/></>
    You can also submit data by associating a function with a form button in a similar way.
    <form onSubmit="doAJAXSubmit();return false;" >
    <input type="text" id="tf1" />
    <input type="button" id="button1" onClick="doAJAXSubmit()" value="Update"/></>Note that the form "onSubmit" attribute is still set. If the user hits the enter key in the text field the form will be submitted so you still need to handle that case.When updating the page it is recommend you wait to make sure that the AJAX update of the form data was successful before updating the data in the page. Otherwise, the data may not properly update and the user may not know. I like to provide an informative message when doing a partial update and upon a successful AJAX interaction I will then update the page

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.