How can you update two frames simultaneously when submitting a form in PHP?

When submitting a form in PHP, you can update two frames simultaneously by using AJAX to send the form data to the server and then updating both frames with the response. This allows for a seamless user experience without having to reload the entire page.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data here
    $response = "Form submitted successfully!";
    
    // Return response to both frames
    echo json_encode(['response' => $response]);
    exit;
}
?>
<!DOCTYPE html>
<html>
<head>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function(){
            $('form').submit(function(e){
                e.preventDefault();
                $.ajax({
                    type: 'POST',
                    url: 'your_php_file.php',
                    data: $(this).serialize(),
                    success: function(response){
                        $('#frame1').html(response);
                        $('#frame2').html(response);
                    }
                });
            });
        });
    </script>
</head>
<body>
    <form>
        <!-- Your form elements here -->
        <input type="submit" value="Submit">
    </form>
    <div id="frame1"></div>
    <div id="frame2"></div>
</body>
</html>