Home > Web Front-end > JS Tutorial > body text

Example of using the serialize() method to submit form data in jQuery ajax

巴扎黑
Release: 2017-07-03 14:02:32
Original
1384 people have browsed it

Use jQuery ajax's serialize() method to serialize the form into a key-value pair (key1=value1&key2=value2...) and submit it. The following is For an example of using serialize() to serialize a form, interested friends can refer to the following

The data in jQuery ajax is sent to the server in the form of key-value pairs (Key/Value), which can be used when submitting form data using ajax The serialize() method of jQuery ajax serializes the form into key-value pairs (key1=value1&key2=value2...) and submits it. The serialize() method uses standard URL-encoded encoding to represent text strings. The following is an example of using serialize() to serialize a form:

The code is as follows:

$.ajax({
   type: "POST",
   url: ajaxCallUrl,
   data: "Key=Value&Key2=Value2",
   success: function(msg){alert(msg);}
 });
Copy after login

ajax serialize():

The code is as follows:

$.ajax({
         type: "POST",
         url:ajaxCallUrl,
         data:$('#
for
mID').serialize(),// 要提交的表单 
         success: function(msg) {alert(msg);}
     });
Copy after login


Example:
Example of using the serialize() method to submit form data in jQuery ajax

The above is the detailed content of Example of using the serialize() method to submit form data in jQuery ajax. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template