CodesJava

Easy learning with example program codes

jQuery serialize()


Some important features of 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>

Try it

JS Bin on jsbin.com

Sign Up/ Sign In
Ask a Question


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki