Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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
Javascript 什么';从另一个域访问bugzilla Web服务的好方法是什么?_Javascript_Ajax_Web Services_Perl_Bugzilla - Fatal编程技术网

Javascript 什么';从另一个域访问bugzilla Web服务的好方法是什么?

Javascript 什么';从另一个域访问bugzilla Web服务的好方法是什么?,javascript,ajax,web-services,perl,bugzilla,Javascript,Ajax,Web Services,Perl,Bugzilla,我有两个网站products.company.com和bugzilla.internal.com。我想从products.company.com页面访问错误信息。我设置了一个jqueryajax函数来调用bugzilla.internal.com/jsonrpc.cgi。但是,由于跨域脚本限制,这被apache阻止(如预期的那样)。然后我在products.company.com上将ajax发送到一个cgi脚本,然后在该脚本中使用curl将请求发送到bugzilla.internal.com/j

我有两个网站
products.company.com
bugzilla.internal.com
。我想从products.company.com页面访问错误信息。我设置了一个jqueryajax函数来调用
bugzilla.internal.com/jsonrpc.cgi
。但是,由于跨域脚本限制,这被apache阻止(如预期的那样)。然后我在products.company.com上将ajax发送到一个cgi脚本,然后在该脚本中使用curl将请求发送到
bugzilla.internal.com/jsonrpc.cgi
,但现在它说

您没有访问的权限 /jsonrpc.cgi

怎么办


如果它使任务变得更简单,我只想使用该功能。

您有几个选项。您可以让
products.company.com
bugzilla.internal.com
发出请求,让它基本上充当代理


另一种选择是从客户端使用jsonp——这将允许跨域调用。这是一篇关于jsonp入门的非常好的IBM文章。

如果您在products.company.com上的web服务器是Apache,您可以设置ProxyPass

如果您无法修改web服务器配置,那么products.company.com上的一个简单代理cgi就可以完成以下任务:

#!/usr/bin/perl

use LWP::UserAgent;
use CGI qw(:standard);



my $URL='http://bugzilla.internal.com/jsonrpc.cgi';

my $q = new CGI;
my $query = &query_string();

my $req = HTTP::Request->new(POST => $URL);
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);

my $ua = LWP::UserAgent->new;
$res = $ua->request($req);

if ($res->is_success) {
   printf "Content-Type: %s\n\n", $res->header('Content-Type');
   print $res->content;
} else {
   printf "Content-Type: text/plain\n\n";
   print "Error: " . $res->status_line . "\n";
}



print $cgi->header(-type => 'text/xml');
print $response->decoded_content;

跨域脚本限制有几种变通方法。我还没有测试过它,但似乎做了您想做的事情。

jsonp不是只允许我从另一台服务器提取json数据吗?在我的情况下,我想向bugzilla Web服务发送json数据。