Reputation: 117
I have search box and I'm using this code to show the results from mysql databse with almost 9,000,000 raw But becuse I have big database I want it to only show the results when someone type a word and then hit enter, and no data rendering when someone open the page. By defults it's live search box right now
This is my code: but it doesnt work?
$('#search_text').keyup(function(){
var search = $(this).val();
if(search != '')
if (event.key === "Enter")
{
load_data(search);
}
else
{
load_data();
}
});
Upvotes: 1
Views: 43
Reputation: 44145
Just remove the load_data
call in your else
and return
out of the function:
$('#search_text').keyup(function(){
var search = $(this).val();
if(search != '') {
if (event.key === "Enter") {
load_data(search);
} else {
return;
}
}
});
Upvotes: 1