DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Kevin has posted 4 posts at DZone. View Full User Profile

Converting Standard Form Submission Into An AJAX Form Submission Using JQuery

  • submit to reddit
        1) Create the standard form as desired
2) Include the jQuery and the jQuery Form Plugin script references in your html head tag
3) In the jQuery document ready handler bind a listener to the submit button's click event
4) The click listener should call the ajaxSubmit() command that comes with the jQuery Form Plugin

	<script type="text/javascript" src="jquery-1.3.1.js"></script>
	<script type="text/javascript" src="jquery.form.js"></script>
		    $('#ajaxform').ajaxSubmit({target: $('#response')});	
	<form id="ajaxform" method="POST" action="response.html">
	   <input type="text" id="mytest" name="mytest/">
	   <input type="text" id="mytest2" name="mytest2/">
	   <input type="button" id="ajaxsubmit" value="Ajax Submit"/>
	<div id="response"></div>


<div id="result">
this is the response!!!