Submitting a Form Using Ajax - J Query

Problem
You have a form that you would like to submit using Ajax:

Solution

Find the <form>element, and hijack the submit event:

Discussion

What will happen when JavaScript is disabled? The form will be submitted, and the entire page will refresh with the results from the server-side script. I use JavaScript to alter the value of the <input type="hidden" name="usingAJAX" />element from falsetto true. This allows the server-side script to know what to send back as a response— either a full HTML page or whatever data is expected for the Ajax response.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

J Query Topics