I'm programatically posting a form to a PHP form handling script. Is there a way for me to make the form handling script think that the post is being done by ajax? The form handler currently checks for HTTP_X_REQUESTED_WITH in $_SERVER to implement special ajax only logic. I need those codes executed when I post to the form using cURL.
via PHP cURL - http://www.php.net/manual/en/function.curl-setopt.php
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest"));
$result = curl_exec ($ch);
curl_close ($ch);
curl -H "X-Requested-With: XMLHttpRequest" ...
This sends the header "X-Requested-With" with your request. The value ("XMLHttpRequest") is then available in $_SERVER['HTTP_X_REQESTED_WITH']
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With