.submit() 不触发表单

.submit() not firing on form

我有以下表格

<form action="" method="post" name="loginForm" id="loginForm">
    <div id="spinnerInsert">
        <div class="form-content"><input type="text" name="loginUser" id="loginUser" class="validate[required,minSize[3]]" required /><span class="form_highlight"></span><span class="form_bar"></span><label for="loginUser">Username</label><span class="form_hint">Enter your username here</span></div>
        <div class="form-content"><input type="password" name="loginPassword" id="loginPassword" class="validate[required]" required /><span class="form_highlight"></span><span class="form_bar"></span><label for="loginPassword">Password</label><span class="form_hint">Enter your password here</span></div>
    </div>
    <div class="form-content buttons"><p><input name="action-login" type="submit" id="action-login" value="Sign In" class="button confirm" style="width: 140px;" /><br/><a href="">Register</a> &middot; <a href="">Forgot Password</a></p></div>
</form>

然后脚本中的以下代码

$('form#loginForm').submit(function(event) {
    // Get data and submit
    $('#spinnerInsert').spin();
    $.getJSON("lib/class/class.login.php", {loginUser: $('input#loginUser').val(), loginPassword: $('input#loginPassword').val(), queryType: "1"})
    .done(function(response) {
        $('#spinnerInsert').spin(false);
        if(response.success===0){
            // Show Error
            toastr.error(response.message, 'Error');
            // If totalFails > 4, lock account and offer to reset password or email admin
            if(response.totalFails>4) {
                $('article#pageForm').html('<p id="accountLocked">Sorry, your account has been locked. Please <a href="">reset your password</a> or <a href="mailto:adminemail">contact the site admin</a> to unlock your account</p><p><a href="javascript:backToLogin();">Back to Sign In</a></p>');
            }
        } else {
            // Load Authentication Section
            $('article#pageForm').html(response.data);
        }
    });
    event.preventDefault();
    return false;
});

但出于某种原因,每次我按下提交时,它只会重新加载页面。它根本不会触发我的脚本。

昨天还能用,今天不行了,我不记得有做过什么改动。

我也试过$(document).on('submit','form#loginForm',function(event) {

完整演示在 http://spendit.dpdesignz.co/

问题是 .spin() 没有定义。尝试删除包含 .spin() 的那些行并尝试提交您的表单。

$('form#loginForm').submit(function(event) {
    // Get data and submit
    $.getJSON("lib/class/class.login.php", {loginUser: $('input#loginUser').val(), loginPassword: $('input#loginPassword').val(), queryType: "1"})
    .done(function(response) {
        if(response.success===0){
            // Show Error
            toastr.error(response.message, 'Error');
            // If totalFails > 4, lock account and offer to reset password or email admin
            if(response.totalFails>4) {
                $('article#pageForm').html('<p id="accountLocked">Sorry, your account has been locked. Please <a href="">reset your password</a> or <a href="mailto:adminemail">contact the site admin</a> to unlock your account</p><p><a href="javascript:backToLogin();">Back to Sign In</a></p>');
            }
        } else {
            // Load Authentication Section
            $('article#pageForm').html(response.data);
        }
    });
    event.preventDefault();
    return false;
});