相关疑难解决方法(0)

未捕获的TypeError:无法使用'in'运算符在JSON字符串中搜索''

我在我的网站上使用了令牌输入,这是我如何初始化令牌输入:

$(document).ready(function () {           
    var populateValue = document.getElementById('<%= hiddentokenPrePopulate.ClientID%>').value
    $("#<%= tokenEmployee.ClientID%>").tokenInput("../Employee/getEmployeeDetails.ashx", {
        deleteText: "X",
        theme: "facebook",
        preventDuplicates: true,
        tokenDelimiter: ";",
        minChars: 3,
        tokenLimit: 1,
        prePopulate: populateValue
    });
});
Run Code Online (Sandbox Code Playgroud)

脚本停留在这一行:

 prePopulate: populateValue
Run Code Online (Sandbox Code Playgroud)

当我删除这一行时,不会有任何javascript错误,但我需要这个,因为我需要预先填充令牌输入.该populateValue方法是:

[{
    "id": "11566",
    "name": "Smith - White"
}]
Run Code Online (Sandbox Code Playgroud)

有一个javascript错误:

未捕获的TypeError:不能使用'in'运算符在[{"id":"11566","name":"Smith - White"}中搜索'47'

我该如何解决这个错误?

javascript asp.net jquery json jquery-tokeninput

16
推荐指数
1
解决办法
8万
查看次数

标签 统计

asp.net ×1

javascript ×1

jquery ×1

jquery-tokeninput ×1

json ×1