weixin_33735077 2015-11-08 23:40 采纳率: 0%
浏览 19

Ajax事件仅工作一次

when i enter the wrong details and run it. it pops up with the error message, but if i then enter the correct details and click run it again. the sign in button changes to "Connecting..." as it should but then nothing else happens

$(document).ready(function() {

    var width = ( $(".main").width() - 5);
    if (width < 300) {
        $(".logo-img").css({"width":width});
    };

    $("#error").hide();

    $(function() {
        $('#login').on('click', function(e){
            e.preventDefault();

            var token = $('#token').val();
            var username = $('#username').val();
            var password = $('#password').val();
            var remember = $('#remember:checked').val();

            $.ajax({
                url: 'core/functions/ajaxLogin.php',
                method: 'POST',
                data: { 'username' : username,
                        'password' : password, 
                        'remember' : remember, 
                        'token' : token },
                dataType: 'html',
                cache: false,
                beforeSend: function() { $('#login').val('Connecting...') },
                success: function( data ) {
                    if (data == 'success') {
                        setTimeout( "window.location.href='backorderbook';", 500 );
                    } else if( data == 'userorpass' ) {
                        $('#error').fadeIn();
                        $('#error_message')
                           .html('username or password were entered incorrectly');
                        $('#error').delay(3500).fadeOut();
                        $('#login').val('Sign In');
                    };
                }
            });
        });
    });
});
  • 写回答

3条回答 默认 最新

  • 游.程 2015-11-08 23:46
    关注

    run your function with Fiddler .. and/or add the error parameter to your ajax... odds are your web request isn't a success.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度