This happens because the PHP file you are using has no connection to WordPress, the function is never loaded. Use the built-in AJAX-API instead, and it will work fine.
This happens because the PHP file you are using has no connection to WordPress, the function is never loaded. Use the built-in AJAX-API instead, and it will work fine.