send ajax request to php function code example
Example: ajax call too functions.php
<?php
// ajax call to this function
function register_user()
{
$username = $_POST['username'];
echo $username;
die();
}
add_action('wp_ajax_register_user', 'register_user');
add_action('wp_ajax_nopriv_register_user', 'register_user');
?>