I am utilizing ajax to filter a listing. The filter works because it ought to more often than not, however for some queries it returns a clean end result. When this occurs, the error within the console is:
PHP Errors in Ajax Response
from a file known as query-monitor.js
.
Filter JS:
jQuery(operate($){
const search = $('#search');
search.submit(operate(e){
e.preventDefault();
update_results($(this));
});
});
operate update_results (filter) {
$.ajax({
url:filter.attr('motion'),
knowledge:filter.serialize(), // type knowledge
kind:filter.attr('technique'), // POST
success:operate(knowledge){
$('#models-container').html(knowledge); // insert knowledge
}
});
return false;
}
The update_results
operate populates the factor #models-container
with the outcomes. The merchandise I am describing as “clean” has all of the html, however not one of the knowledge.
archive-models.php
<!-- Fashions search bar -->
<type id="search" class="model-search" technique="POST" motion="<?php echo admin_url('admin-ajax.php') ?>">
<p class="model-search-headline">
Search For Fashions
</p>
<enter kind="textual content" identify="modelsearch" placeholder="Kind right here...">
<enter kind="hidden" identify="motion" worth="modelfilter">
<enter kind="submit" worth="">
</type>
<!-- Finish fashions search bar -->
<div id="models-container">
<?php whereas (have_posts()) : the_post(); ?>
<?php
$is_new = get_field('is_new');
$title = get_the_title();
$copy = get_field('preview_text');
$picture = get_field('picture');
$phrases = get_the_terms($publish, 'model-tag');
?>
<div class="model-card<?php echo $is_new ? ' new' : '' ?>">
<?php if ($picture) : ?>
<img class="model-card-image" src="<?php echo $picture['url'] ?>" alt="<?php echo $picture['alt'] ?>">
<?php endif; ?>
<div class="copy-area">
<?php if ($phrases || $is_new) : ?>
<div class="model-card-terms">
<?php if ($is_new) : ?>
<p class="model-card-term new">New!</p>
<?php endif; ?>
<?php foreach ($phrases as $time period) : ?>
<p class="model-card-term"><?php echo $term->identify ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<h2 class="model-card-title"><?php echo $title ?></h2>
<?php if ($copy) : ?>
<p class="model-card-copy"><?php echo $copy ?></p>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
</div>
Let me know if I am lacking necessary data in my query. If there’s a great way to troubleshoot this, please present it within the feedback!