Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: f[s] is not a function for jquery form submission

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?

like image 486
Hierophect Avatar asked Oct 31 '12 22:10

Hierophect


1 Answers

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.

like image 168
Esailija Avatar answered Nov 14 '22 04:11

Esailija