2015-07-21 49 views
0

我有我的网站上这样的代码:

$.ajax({ 
     type: "GET", 
     url: 'http://www.rp-online.de/cmlink/top-news-1.2513701', 
     cache : false, 
     dataType: "xml", 
     success: function(xml) { 
      $(xml).find('title').text(); 
      console.log($(xml).text()); 

      var as = $(xml).find('description').eq(1).text(); 
      $('#av').append(as); 
     }, 
     error:function (xhr, textStatus, thrownError){ 
      console.log(textStatus); 
      $("#result").html(textStatus); 
     } 
    }); 

现在,此代码的工作,其用于从其他网站(RSS源)获取数据。

一切看起来不错,在桌面,IOS,但不是在Android上。 当我打开Chrome和移动仿真时,我在控制台中看到这个: parseerror。 有人知道解决方案吗? 谢谢。

回答

0

你的jquery代码工作正常。我在我的电脑上使用Android模拟器在本机和Chrome浏览器上进行了测试,在这里我有enter image description here

也许您在HTML中遇到问题。检查你是不是复制“IDS”

<html> 
    <head> 
    <title></title> 
    <script src="jquery.js"></script> 
    <script> 

    $.ajax({ 
    type: "GET", 
    url: 'http://www.rp-online.de/cmlink/top-news-1.2513701', 
    cache : false, 
    dataType: "xml", 
    success: function(xml) { 
     $(xml).find('title').text(); 
     console.log($(xml).text()); 

     var as = $(xml).find('description').eq(1).text(); 
     $('#av').append(as); 
    }, 
    error:function (xhr, textStatus, thrownError){ 
     console.log(textStatus); 
     $("#result").html(textStatus); 
    } 
}); 

    </script> 
    </head> 
    <body> 
     <div id="result"></div> 
     <div id="av"></div> 

    </body> 
    </html> 
0

我确认,这上面的代码将只适用于iPad,Nexus 7保护工作,但不支持其他设备。为iPad头是:

状态码:200 OK 内容类型:应用/ RSS + xml的;字符集= UTF-8

而对于iPhone: 状态码:301移到永久 内容类型: text/html