我正在使用mythemeshop.com的主题,链接:https://demo.mythemeshop.com/SociallyViral
我只想在一个类别中显示搜索结果,是否可以在ajax.js文件中进行编辑? 代码ajax.js:
function loadSearchResults(query, $container) {
var search_query = query;
if (!$container.hasClass('ajax-search-results-container')) {
$container = $container.find('.ajax-search-results-container');
}
if (search_query == last_query) {
var $results_container = $container.closest('.search-form').find('.ajax-search-results-container');
if (!$results_container.is(':empty')) {
$results_container.show().closest('.search-form').addClass('ajax-search-box-open');
return false;
}
}
last_query = search_query;
if (search_xhr) {
search_xhr.abort();
}
search_xhr = jQuery.ajax({
url: mts_ajax_search.url,
data: { 'action' : 'mts_search', 'q' : search_query },
beforeSend: function() {
$container.addClass('loading');
},
success: function(data) {
$container.html(data).show().closest('.search-form').addClass('ajax-search-box-open');
}
}).done(function() {
$container.removeClass('loading');
});
}