---
title: "JQuery Ajax方法初实践，基础知识：serialize方法"
author: "arne3166"
date: "2010-11-05T16:50:00Z"
tags: []
categories: ["Web前端"]
slug: "jquery-ajax-serialize"
draft: false
lastmod: "2010-11-05T16:50:51Z"
id: 804072
url: "https://arne3166.iteye.com/blog/804072"
---

jquery中使用ajax时常常需要拼装input数据为’username=abc&password=1111111′这种形式，用JQuery的serialize方法可以轻松的完成这个工作。

 

```
<form id="form1">
  <input id="username" type="text" />
  <input id="password" type="password" />
</form>
```

 

在页面的js代码里面的代码是：

 

```
$("form1").serialize();
```

 结果就是：

结果

’username=abc&password=1111111′