Wordpress中的Ajax

I am making a theme in wordpress and I would like to make a search box like in http://api.jquery.com/, e.g. every time the user click further letter the appropriated posts will be shown. So a think that I have to create php file that will get the first letters (that in the search box) end calculate the appropriated post via wordpress filters. The question is, how can I load this file, because if I load just file in the theme folder, this file will not work with WP's functions course.

Include the wp-blog-header.php file at the top of the PHP file. This will include all the necessary WordPress functions.

require_once(dirname(__FILE__) . '/../../../wp-blog-header.php');