AJAX请求Facebook的图形不工作的IE浏览器 [英] Ajax Requests to Facebook graph not working on IE

查看:98
本文介绍了AJAX请求Facebook的图形不工作的IE浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Facebook应用程序。我试图让喜欢的网址,因为我通过URL的数组迭代并将其添加到应包含喜欢的股利。这是我的Ajax请求:

I am developing a facebook app. I am trying to get the likes for urls as I am iterating through an array of urls and adding it to the div that should contain the likes. This is my ajax request:

 $.ajax({
                  type: "GET",
                  cache: false,
                  url: 'https://graph.facebook.com/?id='+videoUrl,
                  dataType : "json",
                  async: false,
                  header: "application/json",
                  success: function(data) {
                      if(data.shares == null) {
                          likeCount = 0;
                      } else {
                          likeCount = data.shares;
                      }
                  }
          });

这工作完全正常的Chrome浏览器,火狐,Safari浏览器。它并不能在任何IE浏览器。我认为这是一个缓存的问题。请注意,我说的缓存:假的请求。我想JSONP和我喜欢,但我无法要求之外访问它。我也尝试添加这我的PHP:

This works perfectly fine on Chrome, Firefox, Safari. It doesn't work on any IE. I thought it was a caching issue. Notice that I added cache: false to the request. I tried JSONP and I get the likes but I am unable to access it outside of the request. I also tried adding this to my php:

    header("Cache-Control: post-check=0, pre-check=0", false);

它仍然无法正常工作。请帮帮我!

It still doesn't work. Please help me!

推荐答案

我有一个类似的问题。这为我工作:

I was having a similar problem. This worked for me:

$.get('https://graph.facebook.com/?id='+videoUrl+'&callback=?', function(data) {
                  if(data.shares == null) {
                      likeCount = 0;
                  } else {
                      likeCount = data.shares;
                  }
              }, 'json');

在&放大器;回调=?在URL导致jQuery来把它当作JSONP。请参阅<一href="http://stackoverflow.com/questions/2887209/what-are-the-differences-between-json-and-jsonp">What是JSON和JSONP之间的区别? 一个更加详细的解释比我在这里提供。

The "&callback=?" in the url causes jQuery to treat it as JSONP. See What are the differences between JSON and JSONP? for a much more detailed explanation than I could provide here.

这篇关于AJAX请求Facebook的图形不工作的IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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