1

在列表视图中加载所有图像之前,我无法显示加载器。我的应用程序中使用了以下代码。它显示加载器,直到加载所有图像,但问题是,将最后一个 src 值附加到所有图像属性src.请帮帮我。

$.ajax({
    url: "http://www.some.com/",
    type: 'POST',
    data: param,
    dataType: "jsonp",
    success: function (result) {
        $.each(result.results, function (k, v) {
            var searchPic = "http://www.some.com" + $.trim(v.eventIcon);
            var localarray = new Array();

            var c = v.eventText;
            strs = c.slice(0, 60);

            $('[data-role="listview"]').append('<li><a href="eventsview.html?id=' + v.nodeId + '&catname=' + v.eventTitle + '" data-ajax="false"> ' + '<img  alt="img" class="pic1"  src=" ">' + '<h4 >' + v.eventTitle + '</h4>' + '<p>' + strs + '...' + '</p></a></li>');
            $('[data-role="listview"]').listview('refresh');
            imgload(searchPic);
        });
        $('[data-role="listview"]').append('<li id="no-results">There is no record found based on your search criteria, please refine your search.</li>');

    }

});

function imgload(tx) {
    $('.pic1').load(function () {
        $.mobile.loading('hide');
    }).attr('src', tx);
}
});
4

0 回答 0