my example with ajax doesn’t work

Your code is technically correct, though you should be doing ajax calls via the WordPress provided means. Also, your path to ajax-php.php will fail if WP isn’t installed in root.

What does ajax-php.php contain and what are you expecting it to return? If you’re trying to use WordPress functions inside of that file, you need to bootstrap WordPress by including wp-load.php. But again, you probably shouldn’t be doing it that way in the first place, see the link above.