AJAX/JSONP 问题。请求跨域时使用 IE 访问 ID 被拒绝

发布于 2024-10-09 14:03:42 字数 1568 浏览 0 评论 0原文

好的,我们开始吧。我已经在堆栈中搜索了答案,我找到了一些有用的信息,但我想澄清更多的事情。我也在网上搜索答案,但没有真正的帮助。

  1. 我使用过一些 api(yelp、ouside.in)。在 yelp 中,我使用回调函数将脚本注入到 api 的 url 请求头。我在所有浏览器中都工作得很好。但是,当我使用 Outside.in api 调用 url 时,回调不起作用。

在 yelp 中,他们有一个 url 字段,可以像回调=callbackfuncion 一样使用,这样回调就会自动调用。

但在outside.in中没有这样的字段可用。回调函数是否有任何标准命令,无论任何服务器/api如何都可以工作?

  1. 我还尝试了使用 jQuery $.ajax() 函数的标准 ajax 请求。它适用于我的本地电脑的 IE 和其他浏览器,但在 IE 中不起作用,显示错误:访问被拒绝,其他浏览器似乎正常。我的 FF 中的 Firebug 也没有注意到任何错误。

  2. Outside.in 有一个 javascript 示例,但对我来说太难理解

github.com/outsidein/api-examples/tree /master/javascript/browser/

我正在工作的 网站:http://citystir.com 叫喊:yelp.com external.in:outside.in

技术信息:

我正在使用:本地wampserver、用于托管的wordpress、Godaddy、用于远程Linux 的apache。

代码:

使用 Jquery $.ajax

url 如下: "http://hyperlocal-api.outside.in/v1.1/states/Illinois/cities/chicago/stories?dev_key="+key+"&sig ="+signeture+"&limit=3

function makeOutsideRequest(url){
$.ajax({
  url: url, dataType: 'json', type: 'GET',
  success: function (data, status, xhr) {
    if (data == null) {
      alert("An error occurred connecting to " + url +
        ". Please ensure that the server is running and configured to allow cross-origin requests.");
    }else{          
      printHomeNews(data);
    }
  },
  error: function (xhr, status, error) {
    alert("An error occurred - check the server log for a stack trace.");
  }
});

}

谢谢!

Ok, Here we go. I have already searched the Stack for the answer i have found some useful info but i want to clear up some more things. I also search the net for the answer but no real help.

  1. I have worked with some api (yelp, ouside.in). In yelp i use to inject the script to head with the url request to the api with a callback funcion. I worked fine in all browsers. But while using outside.in api when i call the url the callback in not working.

In yelp they have a url field can be used like that callback=callbackfuncion so the callback will automatically called.

But in outside.in there is not such field available. Is there are any standard command for callback function which will work regardless of any server/api?

  1. I also tried a standard ajax request using jQuery $.ajax() function. It worked for my local pc for both IE and other browser but did not working in IE showing the error: access denied, other borwser seems ok. Firebug in my FF also don't notice any errors.

  2. Outside.in has an javascript example but it is too hard to me to understand

github.com/outsidein/api-examples/tree/master/javascript/browser/

site i am working: http://citystir.com
yelp: yelp.com
outside.in: outside.in

Techniqual info:

i am using: wampserver in local, wordpress for hosting, Godaddy, apache for remote with linux.

Codes:

Using Jquery $.ajax

url is like: "http://hyperlocal-api.outside.in/v1.1/states/Illinois/cities/chicago/stories?dev_key="+key+"&sig="+signeture+"&limit=3

function makeOutsideRequest(url){
$.ajax({
  url: url, dataType: 'json', type: 'GET',
  success: function (data, status, xhr) {
    if (data == null) {
      alert("An error occurred connecting to " + url +
        ". Please ensure that the server is running and configured to allow cross-origin requests.");
    }else{          
      printHomeNews(data);
    }
  },
  error: function (xhr, status, error) {
    alert("An error occurred - check the server log for a stack trace.");
  }
});

}

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缱倦旧时光 2024-10-16 14:03:42

今天早上,Outside.in 开发者论坛上也有人提出了这个问题(可能是同一个人提出的)。以下是该讨论的链接:http://developers.outside.in/forum/read/97053< /a>

总而言之,Outside.in API 不支持 JSONP,但 CORS 支持包含在该 API 的下一个版本中,该版本将在不久的将来发布。

This question was asked in the Outside.in developer forums this morning as well (presumably by the same person). Here's a link to that discussion: http://developers.outside.in/forum/read/97053

To summarize, the Outside.in API does not support JSONP, but CORS support is included in the next release of the API, which will hit in the near future.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文