Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Zend框架中的跨域ajax操作_Php_Ajax_Apache_Cross Domain - Fatal编程技术网

Php Zend框架中的跨域ajax操作

Php Zend框架中的跨域ajax操作,php,ajax,apache,cross-domain,Php,Ajax,Apache,Cross Domain,我的应用程序(A)需要通过AJAX(Fineuploader库)将文件上载到我的子域(B)(物理上是其他服务器) 我的解决方案是:在B上设置头以允许A的请求。请参阅控制器操作代码: public function imageAction() { $this->_response->setHeader('Access-Control-Allow-Origin', 'http://' . Zend_Registry::get('config')->main_server-&

我的应用程序(A)需要通过AJAX(Fineuploader库)将文件上载到我的子域(B)(物理上是其他服务器)

我的解决方案是:在B上设置头以允许A的请求。请参阅控制器操作代码:

public function imageAction()
{
    $this->_response->setHeader('Access-Control-Allow-Origin', 'http://' . Zend_Registry::get('config')->main_server->path);
    $this->_response->setHeader('Access-Control-Allow-Headers', 'Content-Type, Content-Range, Content-Disposition, Content-Description');

    $this->_helper->json(array('test'));
}
然后我尝试通过ajax从A调用此操作。请求具有以下标题:

Request URL:http://sub.domain.dev/upload/image
Request Method:OPTIONS
Status Code:403 Forbidden
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Access-Control-Request-Headers:access-control-allow-origin, x-mime-type, origin, x-requested-with, cache-control, x-file-name, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:sub.domain.dev
Origin:http://domain.dev
Referer:http://domain.dev
我做错了什么?谢谢

附言。 当我发送带有以下标题的请求时:

Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Content-Length:0
Host:sub.domain.dev
Origin:http://domain.dev
Pragma:no-cache
Referer:http://domain.dev

我认为服务器发送的标题中存在这个问题。

您是否尝试使用这个jquery插件


.

跨域ajax?你听说过SOP吗?这个有用吗@罗伯特,当然,跨域ajax。也许你能帮我?这是可能的。但我和这些头球有一场战争。@Jon,谢谢。我已经设置了这些标题。但是没有运气:403禁止。我已经找到了原因。Apache返回403选项方法禁止访问。我怎样才能修复它?我使用Fineuploader。但没关系。我认为这是标题中的问题。