How to make something like stackoverflow's similar title search
<p>*<em>UPDATE:</em>*I've already answered my question. But you can still give me advise and i'll take your answer as selected</p>

<p>NOTE: If you don't need to know what I want to do with the codes, just skip the first several paragraphs and directly see the codes and tell me why they doesn't work without error.</p>

<p>I want to make something like stackoverflow's similar title search when you enter your title in the ask page. </p>

<p>I need to split words to make regex and then search in the database. Since my application is in Chinese(no spaces between each words) and I think splitting chinese into meaningful phrases using PHP is too hard. I have an idea splitting it in the client side using  javascript according to chinese IME's characteristic that, for example, if you want to type the word "你好中国" in chinese, people usually type "nihao[space]zhongguo" in IME(note where the space bar is), since '你好'(nihao - hello) is a phrase and '中国'(zhongguo - china) is another. So when people press space bar i record the word he entered before the space and start a timer of 2 seconds , if he or she enters another words clear the timer and continue to record if he or she doesn't, send each words recorded to the server. </p>

<p>Qustion is, is this a good idea? Are there any other convenient way to do this? And why these lines i wrote to test won't work without error.</p>

<p>script:</p>

<pre><code>$(function(){
        var i=0;
        $('#t').keyup(function(e){
            if(e.keyCode==32)
            {
                eval("a"+i+"=$(this).val()");
                i++;
                var timer=setTimeout("for(b=0;b&lt;i;b++){alert(eval('a'+b));}",1000);
                if($("#t").keydown())
                {
                    clearTimeout(timer);
                }
            }
        })
    })
</code></pre>

<p>html:</p>

<pre><code>&lt;input id="t"/&gt; 
</code></pre>
