Reputation: 1020
As in the title i'm trying to make add AJAX to search box on my site but keyup event not firing. I'm using function from this message https://stackoverflow.com/a/17317620/5690756
Anyway here is my code
<nav id="search" class="search-main">
<div class="search-trigger"></div>
<div class="search-general">
<div class="search-close"></div>
<input type="text" value="" id="autocomplete" name="s" class="search-input ui-autocomplete-input" placeholder="Arama" autocomplete="off">
<input type="button" class="search-button">
And js code
jQuery(document).ready(function($) {
$("#autocomplate").on('change keyup paste', function() {
alert("Girdim");
var lastValue = $("#autocomplate").val();
jQuery.ajax({
type : 'post',
url : helper.ajaxUrl,
data : {action : 'load_search_results',query : lastValue
},
beforeSend: function() {
$(this).prop('disabled', true);
},
success : function( response ) {
$(this).prop('disabled', false);
$('#modal_results').html( response );
}
});
});
});
Alert function not working in my code how can i solve this issue i have no idea.
Edit: I have another function for parent element. Can it block input function also i added html code to the beginning for to be clear.
$("#search").click(function () {
if($(this).attr("class")=="search-main"){
$(this).attr("class","search-main expand");
$("#autocomplete").attr("placeholder","Lütfen dizi, oyuncu veya tür adı yazın.");
$("#autocomplete").focus();
}
return false;
});
Upvotes: 1
Views: 2008
Reputation: 3634
You mistyped autocomplate
it does not match with id autocomplete
.
Upvotes: 2