dsf55s1233 2011-02-11 00:40
浏览 78
已采纳

$ .get不返回Internet Explorer中的任何数据

I'm using JQuery's $.get function to fetch a twitter feed and display it on my site. I have no idea why it seems to not be getting any data (i.e. code inside function(d) { ... } doesn't get called). It works fine in everything else I've tried. I have also used this code before with no problems, the only thing I can think of is that it is running through https.

(Note that for the example I've removed the twitter user id from the feed url)

JS:

    $.get('proxy.php?url=http://twitter.com/statuses/user_timeline/999999999.rss', function(d) {    
        $(d).find('item').each(function() {
            var theItem = $(this);
            var title = theItem.find('title').text();


            var date = new Date(theItem.find('pubDate').text());
            var alink = theItem.find('link').text();

            // code ommitted (inserts tweet into page)
        });
  });

proxy.php:

<?php
    // PHP Proxy
    // Loads a XML from any location. Used with Flash/Flex apps to bypass security restrictions
    // Author: Paulo Fierro
    // January 29, 2006
    // usage: proxy.php?url=http://mysite.com/myxml.xml

    $session = curl_init($_GET['url']);                    // Open the Curl session
    curl_setopt($session, CURLOPT_HEADER, false);          // Don't return HTTP headers
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);   // Do return the contents of the call
    $xml = curl_exec($session);                            // Make the call

    $seconds_to_cache = 300; // five mins (60 * 5)
    $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
    header("Expires: $ts");
    header("Pragma: cache");
    header("Cache-Control: maxage=$seconds_to_cache");
    //header("Content-Type: text/xml");   // Set the content type appropriately
    header("Content-Type: application/rss+xml");
    echo $xml;        // Spit out the xml
    curl_close($session); // And close the session
?>

Any ideas / help would be greatly appreciated

  • 写回答

3条回答 默认 最新

  • duancaishun4812 2011-02-11 01:23
    关注

    Figured it out. IE needs the content type to be set to text/xml. I changed the proxy.php script:

    header("Content-Type: text/xml");
    

    and that was all I needed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题