You should use the WP AJAX APIs rather than reinventing them in your home template, e.g.:
functions.php :
// declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)
wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
add_action('wp_ajax_my_action', 'my_action_callback');
add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
function my_action_callback() {
$content="something to send back to the browser";
echo $content;
die(); // this is required to return a proper result
}
Javascript:
jQuery.post(
// see tip #1 for how we declare global javascript variables
MyAjax.ajaxurl,
{
// here we declare the parameters to send along with the request
// this means the following action hooks will be fired:
// wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit
action : 'myajax-submit',
// other parameters can be added along with "action"
postID : MyAjax.postID
},
function( response ) {
alert( response ); //
}
);
Using this you can bypass your broken code and rely entirely on standardised APIs
You can read more about it here:
http://codex.wordpress.org/AJAX_in_Plugins
It also applies to themes