Tag: yahoo

使用jQuery和Yahoo的Geolocation API“无效标签”parsererror

我正在使用jQuery访问Yahoo的Geolocation API。 即使我能够从他们的服务器成功检索数据,我也无法让jQuery成功解析数据。 我已经尝试了$ .ajax()和$ .getJSON,每个都返回相同的失败:parsererror和“invalid label”。 通过我对interwebs的挖掘,我发现“无效标签”很可能是JSON没有被括在括号中的结果,但是在解析之前我无法弄清楚如何将数据包装起来。 我甚至不相信这是问题所在。 这是我的代码: $(document).ready(function() { var url = “http://where.yahooapis.com/geocode?q=39.0334171,-94.8320452&gflags=R&flags=JT&appid=supersecretappid&callback=?”; $.getJSON(url, function() { alert(“success”); }) .error(function(data) { alert(JSON.stringify(data)); }); }); 仅使用$ .ajax的备用版本如下: $.ajax({ url: url, data: {}, dataType: “jsonp”, contentType: “text/plain”, success: function(json) { alert(“success”); }, error: function(x,y,z) { alert(JSON.stringify(x)); } }); 非常感谢提前。

如何使用jQuery访问这些奇怪的JSON项?

可能重复: 选择键中带冒号的JSON对象 如果这是一个重复的问题,我道歉。 我搜索过,我真的做到了! 我想要实现的是一个简单的日期重新格式化为更好的东西,如“2012年3月9日星期五”。 我很乐意使用众多方便的jQuery插件中的一个将现成的“pubDate”值解析为更有用的东西。 不幸的是,有些力量阻止我导入任何其他脚本,包括jQuery UI。 我的上司强制要求的页面模板导入了jQuery,就是这样。 我的JSON数据包含以下代码段: “items”: [ { “title”: “blah blah”, “link”: “http://url.blah.com”, “category”: “category blah”, “pubDate”: “Fri, 09 Mar 2012 16:16:05 -0500”, “y:published”: { “hour”: “21”, “timezone”: “UTC”, “second”: “5”, “month”: “3”, “month_name”: “March”, “minute”: “16”, “utime”: “1331327765”, “day”: “9”, “day_ordinal_suffix”: “th”, “day_of_week”: “5”, “day_name”: “Friday”, “year”: “2012” }, […]

Yahoo YQL RSS – 错误请求

为了使用jQuery创建跨域AJAX请求,我正在尝试使用YQL RSS。 select * from rss where url=’https://www.top1000funds.com/feed/most-popular-posts/’ 我的代码: var feed = “https://www.top1000funds.com/feed/most-popular-posts/”; var yql = “https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22″+encodeURIComponent(feed)+”%22&format=json&diagnostics=true&callback=&rnd=_”+event.timeStamp; console.log(yql); $.getJSON(yql, function(res) { var html = ”; if(res.query && res.query.results && res.query.results.item){ //code goes here } else { html += ‘The feed is currently not available due to server issues. Check back soon!’; } html += ”; […]