What are the common pitfalls to avoid when working with AJAX and passing parameters in PHP?

One common pitfall when working with AJAX and passing parameters in PHP is not properly encoding the data before sending it. This can lead to errors or security vulnerabilities. To avoid this, always use functions like `json_encode()` to encode the data before sending it via AJAX.

// Encode the data before sending it via AJAX
$data = array('param1' => 'value1', 'param2' => 'value2');
$encoded_data = json_encode($data);

// Send the encoded data via AJAX
$.ajax({
    type: 'POST',
    url: 'process.php',
    data: {data: encoded_data},
    success: function(response) {
        // Handle the response from the server
    }
});