为什么我没有通过ajax速记显示结果

时间:2016-02-28 08:07:37

标签: jquery ajax .post

我试图通过ajax简写方法提取一些json数据。通过文本键盘调用,它工作正常,但在按钮提交调用时失败。请有人帮忙。

$(document).ready(function(){
    $('#emcode').keyup(function(){
        var length=$('#emcode').val().length;
        if (length > 4){
            var emcodeValue=$('#emcode').val();
            $.post('jason.php',{emcode: emcodeValue},function(result){          
                $('#feedback').html(result).show();
            }); 
        };
    }); 
});

$('#data-submit').click(function(){
    var length=$('#emcode').val().length;
    if (length > 4){
        var emcodeValue=$('#emcode').val();
        $.post('jason.php',{emcode: emcodeValue},function(result){          
            $('#feedback').html(result).show();
        }); 
    };
});

0 个答案:

没有答案