Post will not load via ajax

All ajax requests should be routed through the handy /wp-admin/admin-ajax.php file.

It works with the great WP hooks system. So you send an “action” with your request and use that as part of the action into which you hook your function.

So, let’s say your ajax call looks like this (with jQuery)

jQuery('a.ajax').click(function(e){
    data = {
        'action': 'wpse31321_action',
        'story': 1 // IDs are easier to deal with...
    }
    jQuery.get(
        'http://www.yoursite.com/wp-admin/admin-ajax.php',
        data,
        function(resp){
            // do stuff with the response.
        }
    );

    e.preventDefault();
});

Then, in your functions.php file or a plugin, you need to hook into wp_ajax_wpse31321_action and wp_ajax_nopriv_wpse31321_action. This is the part that does the work: you have access to the complete WP api inside your hooked function. Get posts, whatever.

wp_ajax_[some_action] is for logged in users. wp_ajax_nopriv_[some_action] is for everyone else. [some_action] is, of course, the action you send along with your request. wpse31321_action in our example.

<?php
add_action( 'wp_ajax_wpse31321_action', 'wpse31321_ajax' );
add_action( 'wp_ajax_nopriv_wpse31321_action', 'wpse31321_ajax' );
function wpse31321_ajax()
{
    // you have access to $_REQUEST, $_POST and $_GET here...
    if( isset ( $_REQUEST['story'] ) )
    {
        $story = get_post( (int) $_REQUEST['story'] );
        if( ! $story ) die( '-1' );
        echo $story->post_content;
        die(); // Always kill the script after echoing out what you need.   
    }
    else
    {
        die( '-1' );
    }
}

You can do whatever you want to manipulate the data before echoing it out. The above is a really simplistic answer, without much error checking or security built in. But it should get you started.

Further reading:

http://wpajax.com/

http://codex.wordpress.org/AJAX_in_Plugins

http://codex.wordpress.org/AJAX