Submitting a form using jQuery AJAX

HTML form, that’s to be submitted by jQuery AJAX.

<form id=”employee” action=”employee.php” method=”POST” name=”contact”>
<div>Name: <input id=”name” type=”text” name=”name” size=”30″ value=”" /></div>
<div>Email: <input id=”email” type=”text” name=”email” size=”30″ value=”" /></div>
<div>Phone: <input id=”phone” type=”text” name=”phone” size=”30″ value=”" /></div>
<div><input id=”submit_btn” type=”submit” name=”submit” value=”Send” /></div>
<div id=”result”></div>

Java Script code using jQuery AJAX


<script type=”text/javascript”>
$(document).ready(function() {
$("form").submit(function() {
var frm = $(‘#employee’);
type: frm.attr(‘method’),
url: ‘/employee.php’,
data: frm.(serialize),
success: function (data) {
error: function(jqXHR, textStatus, )errorThrown{
// log the error to the console
"The following error occured: "+
textStatus, errorThrown
return false;

Permanent link to this article:

Leave a Reply

Your email address will not be published.