ITeye博客

表单异步提交的方法

mywebcode · 2013-11-29 19:10 · Markdown

将遇到的表单异步提交的方式记录一下:

表单异步提交注意点:
a.表单中的name一定要跟java中接收参数的名称一样。
b.表单中提交的参数的个数要跟,java中接收参数的个数一样多。不能多也不能少,否则提交不到。

$.post('addshipaddress.html', $('form#addressForm').serialize(), function(data){
alert(data);
}, 'text');
(1):url //addshipaddress.html 表单提交到哪里

(2):data参数 这里是表单的参数传递 $('form#addressForm').serialize() 注意不能用单引号

如'$('form#addressForm').serialize()' 则会报错

(3):function(data)回调函数 还有一种写法 看如下写法。。另写给个function函数

$.post('addshipaddress.html', $('form#addressForm').serialize(), function(data){
confirmSuccess(data);
}, 'text');

}

function confirmSuccess(data) {
alert(data);
window.location.reload();
}

(4):text 为你想要返回得到的内容的形式, 可以是xml , json ,text 等格式

还有其他提交方式 。。。。。待续。。。。。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。