JavaScript not being called in inline event handler

后端 未结 4 935
逝去的感伤
逝去的感伤 2020-12-21 16:10

Here is my JavaScript:



        
4条回答
  •  星月不相逢
    2020-12-21 16:57

    The uploadForm function is not in global scope, hence it cannot be found. Just define the function outside of the document.ready callback or make it global by assigning it to a property of the window object:

    window.uploadForm = function() {
        // ...
    };
    

    Or a better way, since you are using jQuery, is to bind the event handler with jQuery instead of using inline event handlers:

    $('#yourFormID').on('submit', function() {
        // ...
    });
    

提交回复
热议问题