提交表单,我做了一个ajax防止用于验证的形式submition无法通过AJAX回调函数jQuery中
我通过存储ajaxs做验证返回隐变量...
我的表单不提交由于返回false我在其他环
阿贾克斯返回成功我从jQuery的递交表格后,但我收到
未捕获的类型错误:属性对象#的“提交”不是功能 请帮我.....
我只是储存在我从test.php的获取隐藏字段的值1 ....
但控制台上显示错误$(” #foo“)[0] .submit();
如果我点击提交第二次检查的JavaScript的隐藏价值= 1,并进入真正的环...那么其get提交
预先感谢您
<form id="foo" name="foo" action="pop.php" method="get">
<label for="bar">A bar</label>
<input id="bar" name="bar" type="text" value="" />
<input id="bar1" name="bar1" type="text" value="" />
<input type="hidden" name="statushidden" id="statushidden" value=""/>
<input type="submit" value="submit" id="submit" />
</form>
$(document).ready(function() {
$("#submit").click(function() {
var $form = $(this);
var status = validdata();
if (document.getElementById("statushidden").value=="1")
{
alert("true loop");
return true;
}
else
{
alert("false loop");
return false;
}
});
function validdata()
{
var url = "test.php";
$.ajax({
type: "POST",
beforeSend: function(){},
url: url,
data: $("#foo").serialize(), // serializes the form's elements.
success: function(data)
{
document.getElementById("statushidden").value=data;
console.log($("#foo")[0].submit);
$("#foo")[0].submit(); ///// SHOWING Error on this line///////
}
});
}
});
的错误消失,但形式不提交 – kavinhuh 2013-03-08 09:49:53
@ user1386579在窗体中有GET方法请检查。所以它不会发布数据。将其更改为POST – 2013-03-08 09:52:37
更改为帖子仍然显示错误表单提交行中的jQuery的Ajax .. 是否有任何其他语法提交表单从jQuery的Ajax – kavinhuh 2013-03-08 09:57:40