由网友(奶兔大魔王)分享简介:我加载图片列表到一个div使用jQuery的下列位:I am loading a list of images into a div with the following bit of jQuery :var jewellerDdl = "";v...
我加载图片列表到一个div使用jQuery的下列位:
I am loading a list of images into a div with the following bit of jQuery :
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);
}
我回来的字符串是&LT; UL&GT;
包含一些图片
然而,到.text方法犯规将它们添加到DOM。相反,它只是打印的HTML作为内文的&LT; DIV&GT;
称为divEntryDisplay
However, the .text method doesnt add them to the dom. Instead it just prints the HTML as text inside the <div>
called divEntryDisplay
我做了什么错?
推荐答案
您确实应该使用HTML方式(参见文献这里:的 http://docs.jquery.com/Attributes/html )
You should indeed use the html method (cf. documentation here : http://docs.jquery.com/Attributes/html)
这让你的函数是这样的:
Which makes your function look like this:
function AjaxSucceeded(result) {
$("#divEntryDisplay").html(result.d);
}
相关推荐
最新文章