我试图获取一个以迂回方式提交的表单,因为我需要它在提交之前附加新的输入。由于将附加内容放入实际的 $(form).submit() 函数中不会收集它们进行发布,因此我添加了一个 html 按钮来调用 SubmitCheck(),然后提交实际的函数。
function init() {
$("#submit").click(submitCheck);
//and lots of other stuff
}
function submitCheck() {
//go through fabric canvases, save xml to input.
for (var i=1; i<probNum; i++) {
var csvg = gcanvas[i].toSVG();
$('#output').append("<input type='hidden' name='svg"+probNum+"' value='"+csvg+"'></input>");
}
//make sure a topic was selected. If not cancel submission and don't do anything.
if ($("#topic").val() == '-1')
{
$('#error').html("You must select a valid topic");
} else {
//submit the form
alert('should submit now');
$("form:first").submit();
}
}
但是......它失败了,抛出类型错误:
TypeError: f[s] is not a function
我没有找到有关此特定错误的文档。有任何想法吗?
您有一些意见name="submit"
在您的表单中,它会覆盖本机form.submit
(以编程方式提交表单)在 jQuery 内部调用的方法。您需要将其更改为其他名称。
请参阅附加注释段落文档 http://api.jquery.com/submit/#entry-longdesc.
您还可以使用DOMLint http://kangax.github.com/domlint/查看其他可能的冲突问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)