jQuery 使用Jquery自动提交表单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1961326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
using Jquery to automatically submit form
提问by Rob Chuah
I am trying to submit a form by using jquery automatically after page load
我正在尝试在页面加载后自动使用 jquery 提交表单
$(function(){
$("input[name=name]").val("somename");
$("input[name=email]").val("[email protected]");
$('#aweberform').submit();
});
Both the name/email value can be seen to get populated on the form. But the submit event wont triggered.
可以看到姓名/电子邮件值都填充在表单上。但是提交事件不会触发。
Any one here that can shed any lights ?
这里有人可以发光吗?
thanks !
谢谢 !
采纳答案by Rob Chuah
ok i found out the problem
好的,我发现了问题
apparently the submit input cannot have the name submit
显然提交输入不能有名称提交
<input type="submit" name="submit" value="click to submit!">
changed to
变成
<input type="submit" name="someothername" value="click to submit!">
and that got the problem fixed
这解决了问题
回答by atpatil11
Try this $('#aweberform').submit();
尝试这个 $('#aweberform').submit();
回答by Isaac Bruno
Try this document.getElementById('formId').submit();
尝试这个 document.getElementById('formId').submit();
回答by Hugh Seagraves
I had to remove my Submit button to get $('#myForm').submit()
to work. Not sure why.
我不得不删除我的提交按钮才能开始$('#myForm').submit()
工作。不知道为什么。
回答by Philip Schlump
Add a function in the submit. Seems to work for me.
在提交中添加一个函数。似乎对我有用。
$('#aweberform').submit(function(){return true;});