jQuery serialize()

Some important features of the jQuery serialize() method are;

  • jQuery serialize() method creates a text string in standard URL-encoded notation.
  • It is used in form controls.
  • It serializes the form values, the serialized values can then be used in the URL query string.

Syntax:

$ (selector).serialize()

Example:

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").text($("form").serialize());
});
});
</script>
</head>
<body>
<form action="">
First name: <input type="text" name="Mailid" value="test.com"><br>
Last name: <input type="text" name="UserName" value="Jai"><br>
</form>
<br>
<button>Serialize</button>
<br>
<div></div>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com