Zillow API错误:"否' Access-Control-Allow-Origin'标头存在" [英] Zillow API Error:"No 'Access-Control-Allow-Origin' header is present"

查看:56
本文介绍了Zillow API错误:"否' Access-Control-Allow-Origin'标头存在"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从XML中提取一些Zillow数据,但是在加载XML时遇到了麻烦.我的代码如下(我用URL中的API KEY替换了API密钥):

I am attempting to pull some Zillow data from XML but am having trouble loading the XML. My code is as follows (I replaced the API key with API KEY in URL):

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script>
$.ajax({
url: "http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=API KEY&address=10608+floral+park+lane&citystatezip=20878",
dataType: 'xml',
success: function(data){
    console.log(data);

}

});

</script>

但是,出现以下错误:

XMLHttpRequest无法加载 http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id = API 密钥和地址= 10608 +花卉+公园+车道&citystatezip = 20878.不请求中存在"Access-Control-Allow-Origin"标头资源.因此,不允许使用来源"http://WEBSITE DOMAIN"访问.

XMLHttpRequest cannot load http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=API KEY&address=10608+floral+park+lane&citystatezip=20878. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http:// WEBSITE DOMAIN' is therefore not allowed access.

有人能指出我正确的方向/告诉我到底是怎么回事吗?

Could anybody point me in the right direction / tell me what exactly is going on?

推荐答案

这是跨域请求-仅允许您从自己的域中请求资源.

It's a cross domain request - you're only allowed to request resources from your own domain.

Zillow不支持JavaScript API,因此您需要创建自己的服务器端服务以对其进行查询(向前查询),并且与HTML页面位于同一域中.然后您可以调用它(作为代理).

Zillow doesn't support a JavaScript API so you would need to create your own server-side service that queries it (forwards the query) and sits on the same domain as your HTML page. Then you can call it (as a proxy).

这篇关于Zillow API错误:&quot;否&amp;#39; Access-Control-Allow-Origin&#39;标头存在&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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