What potential pitfalls should be avoided when using the 'action' parameter in PHP AJAX requests?

When using the 'action' parameter in PHP AJAX requests, it is important to avoid potential security vulnerabilities such as SQL injection attacks. To prevent this, always sanitize and validate the 'action' parameter before using it in database queries or other sensitive operations. This can be done by using PHP functions like filter_input() or htmlspecialchars() to clean the input data.

$action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);

// Use the sanitized $action variable in your code