TypeError:f [s]不是jQuery表单提交的函数 [英] TypeError: f[s] is not a function for jquery form submission

查看:89
本文介绍了TypeError:f [s]不是jQuery表单提交的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让表单以迂回的方式提交,因为我需要它在提交之前追加新的输入。由于在实际的$(form).submit()函数中添加附加函数不会收集它们,所以我添加了一个html按钮来调用submitCheck(),然后提交实际函数。

 函数init(){
$(#submit)。click(submitCheck);
//和许多其他的东西
}

函数submitCheck(){
//通过结构画布,将xml保存为输入。
for(var i = 1; i var csvg = gcanvas [i] .toSVG();
$('#output')。append(< input type ='hidden'name ='svg+ probNum +'value ='+ csvg +'>< / input>);
}
//确保选择了一个主题。如果不取消提交,不要做任何事情。
if($(#topic)。val()=='-1')
{
$('#error')。html(您必须选择一个有效的主题);
} else {
//提交表单
alert('现在应该提交');
$(form:first)。submit();
}
}

但是...失败,抛出类型错误:

  TypeError:f [s]不是函数

我没有找到关于这个特定错误的文档。任何想法?

解决方案

您有 name =submit,它覆盖了jQuery中内部调用的本地 form.submit (以编程方式提交表单)的方法。您需要将其更改为其他名称。



请参阅 documentation $ b 您也可以使用 DOMLint 查看其他可能的冲突问题。


I'm trying to get a form to submit in a roundabout way, since I need it to append new inputs before it submits. Since putting appends in the actual $(form).submit() function will not gather them for post, I've added an html button to call a submitCheck(), and then submit the actual function.

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();
    }
}

But... it fails, throwing the type error:

TypeError: f[s] is not a function

I've found no documentation on this particular error. Any ideas?

解决方案

You have some input with name="submit" in your form, which overrides the native form.submit (programmatically submits the form) method that is being called internally in jQuery. You need to change that to some other name.

See the Additional Notes paragraph in the documentation.

You can also use DOMLint to see other possible conflict issues.

这篇关于TypeError:f [s]不是jQuery表单提交的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆