weixin_33719619 2015-08-26 22:36 采纳率: 0%
浏览 400

jQuery $ .post不起作用?

When I submit my form using $.post(), nothing happens at all. No error messages, no response, no nothing. It was working before, but it stopped working randomly.

This is my form:

<form id="login_form" class="drop-form" method="POST">
    <p class="lead">Sign in</p>
    <input class="form-control" name="user_email" type="email" placeholder="Email address" />
    <input class="form-control" name="user_password" type="password" placeholder="Password" />
    <input class="btn btn-sm btn-primary" type="submit" value="Sign in" />
</form>

and this is my jQuery:

$('#login_form').submit(function(e) {
    e.preventDefault();

    $.post("core/login.php", $(this).serialize(), function(res) {
        console.log('sent to core/login');
        // handle response
    }, 'json');
});

Chrome's browser console doesn't even show the "sent to core/login". What gives? Like I said, it was working before, and randomly it just stopped working.

  • 写回答

1条回答 默认 最新

  • 游.程 2015-08-26 22:41
    关注

    The 'sent to core/login' message would not appear until you get a success response back, so your problem is likely on the server side. The code you posted works fine client side, it's just not getting a response from 'core/login.php'

    评论

报告相同问题?