选择的多选框值在回调中变为NULL

时间:2016-10-27 15:01:06

标签: javascript jquery

所以,这是一个奇怪的事情。我有一个“选择”多选框,它有值。我在整个代码中都放置了控制台日志语句,并且我的所有值都返回了我的值,但是当我在接受回调并返回数据的JAVA方法中放置一个断点时 - 该值为NULL。这是一些示例代码。

$("#dropdownBox").chosen({});
$("#dropdownBox").change(function() {
$('#dropdownBox').trigger("chosen:updated");
 var tText = $("#dropdownBox").val();
console.log("TText is " + tText);

这将返回在控制台中选择的值 - 并在选择多个项目时返回列表     });

稍后在文件中使用单独的方法

var type = $("#dropdownBox").val();
    console.log("type on the call is = " + type);
 //This returns the same value as before
    $.request({
        url : 'urlToGetData',
        callback : loadJournalListCallback,
        callbackError : function(data) {
            $('#search-button, #clear-button').enable();
            $('#modal-srch-button, #modal-clr-button').enable();
            showErr(data, 4000);
        },
        data : {
            siteId : siteId,
            tType : type
        }
    });

0 个答案:

没有答案