我正在使用以下代码在加载时通过 ajax 从服务器获取内容。但在特定情况下,我有一些完全相同的链接。在这种情况下,我如何防止我的代码对同一个 url 进行多个服务器/ajax 调用但替换不同的 div。
jQuery('.js-ajaxfill').each(function(i){
var _this = jQuery(this);
jQuery.ajax({
url: _this.data('href'),
success: function( data ) {
_this.children('div').replaceWith(data);
},
error : function(jqXHR, textStatus, errorThrown){
_this.html("");
}
});
});