Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

报错的内容:

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

解决方案:

参考的url:

    http://stackoverflow.com/questions/23723005/uncaught-typeerror-cannot-read-property-tolowercase-of-undefined

对象没有正确:

incorrect:

    

$("#type").change(function(){
    //获取选中的
    if($(this).val()==''){
        return;
    }
    var choose= new Array();
    $("input[name='choose[]']:checkbox").each(function(){
        if($(this).prop("checked") == true){
            choose.push($(this).val());
        }
    });
    if(choose == ''){
        layer.msg("没有选中频道",{icon:2,time:2000});
        return ;
    }
    layer.confirm('确定要将选中的频道添加到该机型中?', {icon: 3, title:'提示'}, function(index){
        $.ajax({type:"post",timeout:"",url:"",
            data:{choose:choose,tvmodel_id:$("#this").val()},success:function(data){
            var obj = JSON.parse(data);
            layer.msg(obj.msg, {icon: obj.code,time:1000},function(){
                if(obj.code == '1'){
                    window.location.reload();
                }
            });
        }});

    });


});

上图中的this对象已经变了。注意这一点

将this修改成#type ,也就是select标签即可

转载于:https://my.oschina.net/linuxphp/blog/756988

你可能感兴趣的:(Uncaught TypeError: Cannot read property 'toLowerCase' of undefined)