English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The serialize() method creates a URL-encoded text string by serializing the form values.
We can select one or more form elements (such as input and/Or text area), or you can also select the form element itself.
When making AJAX requests, you can use serialized values in the URL query string.
$(selector).serialize()
Output the result of serialized form values:
$("button").click(function(){ $("p").text($("form").serialize()); });Test and see‹/›
Serialize form to query string:
$(document).ready(function(){ function showValues() { let str = $("form").serialize(); $("p").text(str); } $("input[type='checkbox'], input[type='radio']").on("click", showValues); $("select").on("change", showValues); });Test and see‹/›