TypeError:f 不是jquery表单提交的函数

我正试图以迂回的方式提交表单,因为我需要在提交之前附加新的输入。 因为在实际的$(form).submit()函数中添加appends不会收集它们的post,我添加了一个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(""); } //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"输入,它会覆盖在jQuery内部调用的本机form.submit (以编程方式提交表单)方法。 您需要将其更改为其他名称。

请参阅文档中的附加说明段落。

您还可以使用DOMLint查看其他可能的冲突问题。