How to use serialize() Method in JQuery AJAX
In this article, I will explain use of serialize() Method in JQuery AJAX.
JQuery AJAX serialize() Method
- serialize() method creates a URL encoded text string by serializing form values when making an AJAX request..
- serialize() method operates on a jQuery object representing a set of form elements.
Syntax
Example
The following example show the use of serialize() method.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("button").click(function () {
$("div").text($("form").serialize());
});
});
</script>
</head>
<body>
<h2>serialize() Method Example</h2>
<form action="">
First name: <input type="text" name="FirstName" value="Dinesh" /><br />
Last name: <input type="text" name="LastName" value="Kumar" /><br />
</form>
<button>Click for serialize form values</button>
<div></div>
</body>
</html>
|
Output
You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here