您的位置:首页 > 其它

表单异步提交的方法

2013-11-29 19:10 225 查看
将遇到的表单异步提交的方式记录一下:

表单异步提交注意点:

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 等格式

还有其他提交方式 。。。。。待续。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: