jquery .text不会将HTML元素呈现到DOM中

Chr*_*sCa 0 ajax jquery

我正在使用以下jQuery加载一个图像列表到div:

                var jewellerDdl = "<%= JewellerDropDownList.ClientID %>";
                var filter = $("#" + jewellerDdl).val();

                $.ajax({
                    type: "POST",
                    url: "popup.aspx/GetJewellerAssets",
                    contentType: "application/json; charset=utf-8",
                    data: '{"jewellerId":' + filter + '}',
                    dataType: "json",
                    success: AjaxSucceeded,
                    error: AjaxFailed
                });

                function AjaxSucceeded(result) {
                    $("#divEntryDisplay").text(result.d);
                }

                function AjaxFailed(result) {
                    alert(result.status + ' - ' + result.statusText);
                } 
Run Code Online (Sandbox Code Playgroud)

我回来的字符串<ul>包含一些图像

但是,.text方法不会将它们添加到dom中.相反,它只是将HTML作为文本打印在被<div>调用的divEntryDisplay中

我做错了什么?

Gui*_*dre 5

你应该使用html方法(参见文档:http://docs.jquery.com/Attributes/html)

这使你的功能看起来像这样:

 function AjaxSucceeded(result) {
    $("#divEntryDisplay").html(result.d);
 }
Run Code Online (Sandbox Code Playgroud)