TypeError: e[h] is not a function

后端 未结 6 989
说谎
说谎 2020-12-28 18:20

I\'ve been using jquery 1.6 with no problem. Today I switched to jquery 1.8 and suddenly I am getting this error when trying to submit a form:

TypeError: e[h         


        
相关标签:
6条回答
  • 2020-12-28 18:35

    Remove the line below.

    <input type="submit" name="login" id="submit" style="visibility:hidden" />
    

    Update:

    Or if you have to use the submit input, then you need to change the id submit to something else. The reason is that if you have an input element with id of submit, it will set a submit property to the form with the HTMLInputElement. So you could not call the .submit method on the HTMLFormElement.

    0 讨论(0)
  • 2020-12-28 18:36

    i think it's because the line

    <input type="submit" name="login" id="submit" style="visibility:hidden" />
    

    can you remove it and retry?

    0 讨论(0)
  • 2020-12-28 18:38

    I waster 3 hours trying to fix the same issue, I was using the name='submit' for my submit button and was calling $("#form_name").submit(); in a function and was getting the error. Sometimes small things I overlook end up wasting lot of time.

    0 讨论(0)
  • 2020-12-28 18:41

    Your form and input have the same name attribute value, login.

    Change the name on the input to something else, like submit. This should clear up your error.

    0 讨论(0)
  • 2020-12-28 18:42

    With jQuery 1.7 (possibly above too) if you have the name property also called submit it will break.

    E.g.

    <input type="submit" name="submit" value="Upload">

    Will not work, however:

    <input type="submit" name="sendSubmit" value="Upload">

    Is fine.

    0 讨论(0)
  • 2020-12-28 18:43

    When we use a submit type element in a form, This element will be set as Submit property of the form. So one could not call the submit() function with other element of form.

    There are two ways to do this. first one is just remove the line as given in first reply.

    Or Use $("#submit").trigger("click"); instead of $("#login").submit();. and it will submit the form on pressing enter key word too.

    0 讨论(0)
提交回复
热议问题