Wetts's blog

Stay Hungry, Stay Foolish.

0%

jQuery-提交表单

表单提交方法有三种,主要说下第三种

  1. 用form自带属性action提交
  2. 用jquery提交:$(“#formid”).submit()
  3. 用ajax提交

但如果form表单中数据很多时,不可能一一列出,只需要用$('#yourformid').serialize()就可以了

举例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
$.ajax({
cache: true,
type: "POST",
url:ajaxCallUrl,
data:$('#yourformid').serialize(),// 你的formid
async: false,
error: function(request) {
alert("Connection error");
},
success: function(data) {
$("#commonLayout_appcreshi").parent().html(data);\
}
});