weixin_33674437 2015-07-20 16:07 采纳率: 0%
浏览 25

检查空数据库值

Below is the object returned from backend:

[Object]0: Object Option_Name_0: null Option_Name_1: "me" Option_Name_2: "you" Option_Name_3: "get" Option_Name_4: "no"__proto__: Objectlength: 1__proto__: Array[0]

I am just trying to populate the values into dropdown menu, by removing "null" value.

$.each(e, function(i) {
    $.each(e[i], function(key, val) {
        if (val != 'null') {
            $(".flash_bet_win").append("<option value=" + val + ">" + val + "</option>");

        }

    });
});

But still I see "null" value in dropdown menu. How to fix this?

  • 写回答

2条回答 默认 最新

  • weixin_33713350 2015-07-20 16:10
    关注

    In your if statement, you're checking that that it's not equal to string 'null', when you want to check if it's equal to the value null

    if(val != null)
    

    Or, even shorter:

    if(val)
    

    Does this do the trick?

    评论

报告相同问题?