This is more of an hack but i couldn’t find any other way around, tried exact= "true"
and sentence="true"
as parameters in the query but still, i had all results not only the exact matching one. Therefore since I was having the results as a list
, i am doing a check in the DOM
and removing anything which doesn’t exactly match the .val()
function searchAjax(){
jQuery.ajax({
url: '<?php echo admin_url('admin-ajax.php'); ?>',
type: 'post',
data: { action: 'data_fetch', exactwords: jQuery('#usp-title').val() },
success: function(data) {
var text2;
var text2B;
text2 = jQuery('#usp-title').val();
text2B = text2.toLowerCase();
jQuery("#datafetch").html(data).promise().done(function(){
jQuery("#datafetch ul li h2 a").each(function() {
var $this = jQuery(this);
if ($this.text().toLowerCase() !== text2B) {
$this.parent().parent().remove();
jQuery(".jumbotron").remove();
jQuery("#componi").removeAttr("disabled", "disabled").show();
} else if ($this.text().toLowerCase() == text2B) {
jQuery("#componi").attr("disabled", "disabled").hide();
}
});
});
}
});
}