I have a show image inside my Jquery autocomplete source function and it isn't working.
I set a break point in the show inside my source function in chrome developer tools. The function is getting called but nothing is happening. The hide and show outside my autocomplete function works.
Here is my code.
echo '
<div id="divAuthorSearch" style="padding: 3px;"><img src="https://www.jqueryscript.net/images/jQuery-Ajax-Loading-Overlay-with-Loading-Text-Spinner-Plugin.jpg"/></div>
<script>
$("#divAuthorSearch").hide();
$("#divAuthorSearch").show();
</script>
<style>
.ui-autocomplete {
max-height: 200px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
/* add padding to account for vertical scrollbar */
padding-right: 20px;
}
</style>
<script>
$("#authorname").autocomplete({
minLength: 3,
source: function(request, response){
$("#divAuthorSearch").show();
$.ajax({
"url" :"/koauthor/SelectEmployee",
"type" : "POST",
"data" : JSON.stringify({"name": request.term}),
"contentType" : "application/json",
"success" : function(data) {
response(data);
},
"error" : function(error)
{
alert("error: "+JSON.stringify("There was an error!"));
}
});
$("#divAuthorSearch").hide();
}
}).focus(function(){
$(this).autocomplete("search", "");
});
The $("#divAuthorSearch").show(); inside my source function should show an image, then the image should hidden after $("#divAuthorSearch").hide(); is called.