从卷曲发布:HTTP_X_REQUESTED_WITH [英] Posting from cURL: HTTP_X_REQUESTED_WITH

查看:145
本文介绍了从卷曲发布:HTTP_X_REQUESTED_WITH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程方式提交表单的PHP表单处理脚本。有没有办法为我做的表单处理脚本认为职位是由AJAX做了什么?表单处理程序目前检查HTTP_X_REQUESTED_WITH在$ _ SERVER实行特殊的AJAX只是逻辑。我需要那些codeS执行时将帖子发到形式使用卷曲。

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.

推荐答案

通过PHP卷曲 - <一个href="http://www.php.net/manual/en/function.curl-setopt.php">http://www.php.net/manual/en/function.curl-setopt.php

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); 

这篇关于从卷曲发布:HTTP_X_REQUESTED_WITH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆