我正在编辑wordpress
页面,但没有做任何异常操作,但是我的主页突然失去了背景色(现在边框是白色的,但是页面中间应该是白色的)。
我的控制台不断向我扔:
Uncaught TypeError: Cannot read property 'replace' of undefined
at HTMLButtonElement.<anonymous> (ajax-filter-posts.js?ver=1:57)
at HTMLDivElement.dispatch (jquery.js?ver=1.12.4:3)
at HTMLDivElement.r.handle (jquery.js?ver=1.12.4:3)
at Object.trigger (jquery.js?ver=1.12.4:3)
at Object.a.event.trigger (jquery-migrate.min.js?ver=1.4.1:2)
at HTMLButtonElement.<anonymous> (jquery.js?ver=1.12.4:3)
at Function.each (jquery.js?ver=1.12.4:2)
at a.fn.init.each (jquery.js?ver=1.12.4:2)
at a.fn.init.trigger (jquery.js?ver=1.12.4:3)
at HTMLDivElement.<anonymous> (ajax-filter-posts.js?ver=1:76)
该怎么办?我的 ajax-filter-posts.js?ver = 1:57 看起来像这样:
(function($) {
$doc = $(document);
$doc.ready( function() {
/*Retrieve posts*/
var container = $('.container-async');
container.each(function() {
var $movie_tab_id = $(this).attr('id'),
$movie_tab = "#" + $movie_tab_id,
$content = $($movie_tab).find('.category-content.flw');
function get_posts($params) {
$.ajax({
type: 'POST',
url: blockter.ajax_url,
data: {
action: 'do_filter_posts',
nonce: blockter.nonce,
params: $params
},
dataType: 'json',
success: function(data, textStatus, XMLHttpRequest) {
if (data.status === 200) {
$content.html(data.content);
}
else if (data.status === 201) {
$content.html(data.message);
}
},
error: function(MLHttpRequest, textStatus, errorThrown) {
},
complete: function(data, textStatus) {
msg = textStatus;
if (textStatus === 'success') {
msg = data.responseJSON.found;
}
$content.removeClass('loading');
}
});
}
$($movie_tab).on('click', 'button[data-filter], .category-pagination li a', function(event) {
if(event.preventDefault) { event.preventDefault(); }
var $this = $(this),
$mediaType = null;
/*Set filter active*/
if ($this.data('filter')) {
$this.addClass('active').siblings().removeClass('active');
$page = $this.data('page');
$mediaType = $this.data('media');
$postin = $this.data('postin');
}
else {
/*Pagination*/
$page = parseInt($this.attr('href').replace(/\D/g,''));
$mediaType = $this.parent().data('media');
$postin = $this.parent().data('postin');
$this = $('.category-filter button.active');
}
$content.addClass('loading');
$content.append('<div class="ajaxloading"></div>');
$params = {
'page' : $page,
'tax' : $this.data('filter'),
'term' : $this.data('term'),
'qty' : $this.closest($($movie_tab)).data('paged'),
'media': $mediaType,
'postin': $this.data('postin'),
};
/*Run query*/
get_posts($params);
});
$('button[data-term="all-terms"]').trigger('click');
});
var $movie_tab_id = $('.container-async').attr('id'),
$movie_tab = "#" + $movie_tab_id,
$content = $($movie_tab).find('.category-content.flw'),
$contents = $($movie_tab).find('.category-content.specific');
$($movie_tab).on('click', 'button[data-filter], .category-pagination li a', function(event) {
$.ajax({
type: 'POST',
url: blockter.ajax_url,
data: {
action: 'do_filter_posts',
nonce: blockter.nonce,
params: $params
},
dataType: 'json',
success: function(data, textStatus, XMLHttpRequest) {
if (data.status === 200) {
$content.html(data.content);
$contents.html(data.content);
}
else if (data.status === 201) {
$content.html(data.message);
$contents.html(data.message);
}
},
error: function(MLHttpRequest, textStatus, errorThrown) {
},
complete: function(data, textStatus) {
msg = textStatus;
if (textStatus === 'success') {
msg = data.responseJSON.found;
}
$content.removeClass('loading');
$contents.removeClass('loading');
}
});
$contents.addClass('loading');
$contents.append('<div class="ajaxloading"></div>');
});
});
})(jQuery);
并指出错误在这里:
/*Pagination*/
$page = parseInt($this.attr('href').replace(/\D/g,''));
$mediaType = $this.parent().data('media');
$postin = $this.parent().data('postin');
$this = $('.category-filter button.active');