我用ajax函数的响应绑定一个div,如下所示
BindProductFamilyList: function (str) {
var _obj= new Object();
_obj.id= str;
$.ajax({
url: 'page.aspx/Bind',
data: JSON.stringify({ 'obj': _obj}),
dataType: "json",
contentType: "application/json; charset=utf-8",
cache: false,
async: false,
type: 'POST',
beforeSend: function () {
$("#divLoader").fadeIn();
},
complete: function () {
},
success: function (response) {
var _strInnerHtml = "";
$("#div").html(_strInnerHtml);
// Loop and bind the parameter header
$.each(response, function (key, value) {
if (Object.keys(value).length > 0) {
$.each(value, function (key, value) {
// Loop and bind
_strInnerHtml += "<div class='col-sm-6 col-md-4 col-lg-3 mb-5'>";
_strInnerHtml += "<a href='#' title='View Details'class='prod-box wow fadeInUp'>";
_strInnerHtml += "<img class='img-fluid' src='data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' data-src='../uploads/pic/" + value.pic + "' title='" + value.name + "' alt='" + value.name + "' />";
_strInnerHtml += "<h2>" + value.name + "</h2>";
_strInnerHtml += "</a>";
_strInnerHtml += "</div>";
});
}
else {
_strInnerHtml = "No records.";
}
});
$("#div").html(_strInnerHtml);
$("#divLoader").fadeOut();
},
error: function (xhr, ajaxOptions, thrownError) {
//alert(xhr.status);
//alert(thrownError);
}
});
}
$(document).on("change", ".catfilter", function () {
ns.BindProductFamilyList(ns.GetSelectedId());
});
第一次调用此函数时,图像被正确加载。当我在checkbox list的change事件上调用这个函数时。不加载图像,只加载数据64图像,而不加载文件夹中的实际图像。我怎么解决这个问题?