简体   繁体   English

用于跨域AJAX脚本编写的PHP代理

[英]PHP proxy for cross-domain AJAX scripting

I have set up a simple php proxy 我已经建立了一个简单的php代理

 $proxy = 'tcp://127.0.0.1:8080';

 $context = array(
    'http' => array(
               'proxy' => $proxy,
               'request_fulluri' => True,
    ),
 );

 $context = stream_context_create($context);

 $body = file_get_contents("http://www.php.net", False, $context);
 print $body

I want to be able to make ajax request from one subdomain to another. 我希望能够从一个子域向另一个子域发出Ajax请求。 Unfortunately the code above does not work yet. 不幸的是,以上代码尚无法正常工作。 When I make an request the script loads for a long time without success. 当我发出请求时,脚本加载了很长时间却没有成功。

Any ideas? 有任何想法吗?

I'm not sure if you understood AJAX proxy correctly. 我不确定您是否正确理解AJAX代理。 Check out this article , it's stated there that PHP script itself is a proxy, so there's no need to use tcp proxy via streams. 查阅本文 ,那里有PHP脚本本身是代理的说明,因此无需通过流使用tcp代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM