How can jQuery be used to handle CORS requests in PHP?

When making cross-origin requests from jQuery to a PHP server, CORS (Cross-Origin Resource Sharing) issues may arise due to security restrictions. To handle CORS requests in PHP, you can set the appropriate headers in your PHP script to allow cross-origin requests from specific domains. This can be achieved by sending the 'Access-Control-Allow-Origin' header with the value of the requesting domain.

<?php
header("Access-Control-Allow-Origin: http://example.com");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");