RadComboBoxItem set_text给出了SyntaxError:非法字符

时间:2016-02-16 16:39:03

标签: asp.net ajax telerik radcombobox

我正在使用Telerik UI for ASP.NET AJAX,我正在尝试填充RadComboBox,但我收到此错误,我不知道为什么。

我的RadComboBox

<telerik:RadComboBox ID="regTypeComboBox" runat="server" Width="305" Skin="Telerik" OnClientLoad="OnClientLoadHandler" />

我的js:

function OnClientLoadHandler(sender) {
    var combo;
    combo = sender;

    var serviceUrl = "myUrl";

    var paramData = {

    };

    $.ajax({
        type: 'GET',
        url: serviceUrl,
        contentType: 'application/json; charset=utf-8',
        crossDomain: true,
        data: JSON.stringify(paramData),
        dataType: 'json',
        success: function (response) {
            var listData = response.listData;
            $.each(listData, function (index, element) {
                var name, id;
                name = element.NAME;
                id = element.ID;
                var comboItem = new Telerik.Web.UI.RadComboBoxItem();
                comboItem.set_text(name); // --> SyntaxError: illegal character

                //comboItem.set_text("name"); // --> also SyntaxError: illegal character

                //comboItem.set_text(""); // --> also SyntaxError: illegal character
                //comboItem.set_text(); // --> also SyntaxError: illegal character
                //comboItem.set_text(1); // --> also SyntaxError: illegal character
                combo.trackChanges();
                combo.get_items().add(comboItem);
                combo.commitChanges();
            });

},
        error: function () {
            alert("error");
        }
    });
}

这很简单,但我不知道为什么会出现这个错误。

有什么想法吗?感谢

0 个答案:

没有答案