wordpress add_action() issue in ajax call

You’re sending your AJAX request to the wrong place. Of course calling functions.php directly will get you undefined function errors, because the WordPress API isn’t loaded by functions.php ( it’s the other way round ). A car doesn’t make fuel go forward, fuel makes a car go forward, simply getting in the car won’t make fuel magically appear, in the same way loading functions.php won’t magically make all the WordPress APIs appear.

Also, using files in your theme as AJAX and form submission endpoints is a huge security hole. Even if you change theme, those endpoints are still there, and can still be used.

So instead, use the official ajax endpoint:

http://codex.wordpress.org/AJAX_in_Plugins

When you enqueue your script, also localise a variable to pass the url of the endpoint to your javascript:

// in JavaScript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value
wp_localize_script( 'ajax-script', 'ajax_object',
        array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );

Then in your javascript, the endpoint will be:

ajax_object.ajax_url

A final note

All your work will be destroyed on the next update of twentyten. Instead of modifying the twentyten theme, create a child theme and put your modifications there. This way you can update the default themes without loosing any changes