【发布时间】:2014-04-06 01:14:06
【问题描述】:
我开发了使用 JQuery 获取 JSON 数据的工具,但问题是一些变量没有输入它们的值,而且我只得到了像文本一样的变量名称。这是代码
$(document).ready(function(){
$('.HTML').each(function(){
var call = $.getJSON('http://test-khamsat-support-gig.blogspot.com/feeds/posts/default/-/Break?max-results=10&orderby=published&alt=json-in-script&callback=?',function(data){
var cont = data.version;
});
var th = $(this);
var b = th.html(),
a = b.match(/[^[\]]+(?=])/g);
if(a){
if(a[2] == 'one'){
th.append("<h1>'+cont+'</h1>")
}
}
});
});
代码将仅在我的博客中运行,因为它包含我的 blog 提要
【问题讨论】:
-
这是跨域请求吗?
-
首先,在 ajax 请求中你不能这样做 - stackoverflow.com/questions/14220321/…
-
第二个因为
cont是一个变量th.append("<h1>"+cont+"</h1>") -
这个问题不值得投 2 票。
-
@Liam 下面的答案效果很好。非常感谢您的宝贵时间。
标签: javascript jquery