What are the limitations of accessing PHP code from JavaScript on the client side?

When accessing PHP code from JavaScript on the client side, one limitation is that PHP code is executed on the server side before the page is sent to the client, so JavaScript cannot directly interact with PHP code. To overcome this limitation, you can use AJAX to make asynchronous requests to the server and retrieve data from PHP scripts.

// PHP code to handle AJAX request
if(isset($_POST['data'])) {
    $data = $_POST['data'];
    
    // Process the data
    
    echo json_encode($result);
}
```

```javascript
// JavaScript code to make AJAX request to PHP script
var data = 'example_data';

$.ajax({
    type: 'POST',
    url: 'example.php',
    data: {data: data},
    success: function(response) {
        // Handle the response from PHP script
    }
});