【问题标题】:Prototype + Flickr Ajax Request doesn't work with FirefoxPrototype + Flickr Ajax 请求不适用于 Firefox
【发布时间】:2010-06-24 17:32:11
【问题描述】:

大家好,我有一个奇怪的问题,我一直在使用 Flickr API,在 Flickr 中与服务器建立连接是通过 url 格式在我的情况下类似这样的

http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=10cb3dccaa050efebdc01540c1d4d227&user_id=51390557@N07&format=json

如果您运行到任何浏览器,您将获得一个 flickr 功能并且没问题,但我试图通过 Prototype 的 Ajax 获得我正在做类似的事情

    new Ajax.Request('http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=10cb3dccaa050efebdc01540c1d4d227&user_id=51390557@N07&format=json',
  {
    method:'get',
    onSuccess: function(transport){
        debugger;
      var response = transport.responseText || "no response text";
      alert("Success! \n\n" + response);
    },
    onFailure: function(){ alert('Something went wrong...') }
  });

并且在 IE 中运行良好,但在 Firefox 中我不知道为什么我在 responseText 中得到一个空白字符串“”。有没有人知道我做错了什么?

谢谢

【问题讨论】:

标签: javascript ajax prototypejs flickr


【解决方案1】:

我想答案是因为 firefox 不接受跨域调用,所以为此我们可以使用 JSONP,Prototype JS 的实现可以在以下位置找到:dandean.com/jsonp-for-prototypejs 希望有人帮助这个问题和答案未来的自我问题=)

最好的 那鸿

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-27
    • 2023-04-07
    • 1970-01-01
    • 2013-03-02
    • 2012-12-21
    • 2019-12-02
    • 2014-04-26
    • 2016-03-20
    相关资源
    最近更新 更多