我正在从数据库中获取数据,但其中一个是像这样的图像文件路径'~\images\food.png',但我想将它放在一个 img 标签中,这样它就可以显示图像而不是路径。请有人帮忙,在此先感谢。
$(document).ready(function () {
load();
});
function load() {
$.ajax({
type: "POST",
url: "ParentCategoryManagment.aspx/PopulateCategories",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: AjaxSucceeded,
error: AjaxFailed
});
}
function AjaxSucceeded(respone) {
var json = jQuery.parseJSON(respone.d);
if (typeof oTable == 'undefined') {
oTable = $('#tblData').dataTable({
'aaData': json,
'aoColumns':
[
{ "mDataProp": "Id" },
{ "mDataProp": "Name" },
{ "mDataProp": "ImagePath" },
{ "mDataProp": null, "sDefaultContent": '<a class="edit" href="">Edit</a>' },
{ "mDataProp": null, "sDefaultContent": '<a class="delete" href="">Delete</a>' }
]
});
}
else {
oTable.fnClearTable(0);
oTable.fnAddData(json);
oTable.fnDraw();
}
}
function AjaxFailed(result) {
alert('Ajax Failed');
}