1)将form表单数据序列化
- <span style="font-size:18px;"> $.ajax({
- type: "POST",
- url:your-url,
- data:$('#yourformid').serialize(),
- async: false,
- error: function(request) {
- alert("Connection error");
- },
- success: function(data) {
- //接收后台返回的结果
- }
- });</span>
这种方式需要注意的是form表单中的项一定要有name属性,后台获取的键值对为key=name值,value=各项值,注意无论是input标签还是span或者是其他标签,一定要有name属性,没有name属性后台是获取不到该项的
2)通过窗口查找form提交
- <span style="font-size:18px;"> // 提交表单
- var obj = document.getElementById("xx_iframe").contentWindow;
- obj.$("#yourform").form("submit",{
- success :function(data){
- //对结果处理
- }
- });</span>