search with jquery
<p>I do a search by the js for my site.</p>

<p>Their code it might look like:
have a form and when the keyup event, it will send post to a file and retrieve data from that file into the html of a div crazy.</p>

<p>but this yourself in trouble. I find the example for "a" is about 3000 results. for example, take a second to send post. so I press "c" will now send the post to the file is "ac" and there are 100 such results takes 0.3 seconds.
eg time I press the letter "a" to "c" 0.2 seconds, it should show results "ac" at 0.5 seconds. then 0.5 seconds later it is the result of "a". ~> Find "ac" into finding "a"
So how do you now when you press "c" then it stopped send post with the value "a" that send post with value "ac".</p>

<pre><code>&lt;form method="post" onsubmit="return checkForm(this.form)"&gt;
&lt;div class="search padding"&gt;
    &lt;input type="text" id="searchbox" name="manga_name" class="input" value="Tìm truyện muốn đọc ..." onfocus="if (value =='Tìm truyện muốn đọc ...'){value =''}" onblur="if (value ==''){value='Tìm truyện muốn đọc ...'}" /&gt;
    &lt;input type="submit" value=" " id="searchsubmit" class="go"/&gt;
&lt;/div&gt;
    &lt;/form&gt;

&lt;div id="result"&gt;&lt;/div&gt;
</code></pre>

<p>And the script:</p>

<pre><code>&lt;script&gt;
$('#searchbox').keyup(function() {
 search();
});

function search() {
var keyword = $('#searchbox').val();
if (keyword != "") {
$('#result').html(loadingText);
$('#result').css('display', 'block');
$.post('/search/',{"keyword":keyword}, function(data){
if (data != "")
{
$('#result').html(data);
}
else
{
$('#result').html('');
$('#result').css('display', 'none');
}
});
}
else {
$('#result').html('');
$('#result').css('display', 'none');
}
}
&lt;/script&gt;
</code></pre>
