jQuery模板从Twitter拉入JSON提要
我正在尝试获取一个Twitter提要,或者使用,或者仅仅使用下面的代码,我只得到一个空白页面。我已经包含了所有正确的jQuery元素,并使用进行了测试(并更改了相关的模板部分)jQuery模板从Twitter拉入JSON提要,jquery,templates,twitter,Jquery,Templates,Twitter,我正在尝试获取一个Twitter提要,或者使用,或者仅仅使用下面的代码,我只得到一个空白页面。我已经包含了所有正确的jQuery元素,并使用进行了测试(并更改了相关的模板部分) $().ready(函数()){ $(文档).ajaxComplete(函数(){ $(“body”).attribute({message::}); }); $.getJSON('http://twitter.com/status/user_timeline/ladygaga.json?count=10&callba
$().ready(函数()){
$(文档).ajaxComplete(函数(){
$(“body”).attribute({message::});
});
$.getJSON('http://twitter.com/status/user_timeline/ladygaga.json?count=10&callback=?,函数(数据){
$.template(“imageTmpl”,$(“#imagesTmpl”);
$.tmpl(“imageTmpl”,数据{
}).附于(“#img#U列表”);
});
});
{{每项}}
{{如果$index
更改模板语法,在这种情况下不需要每个,模板引擎会显示默认情况下获得的每个数组键
注意你的括号-右边的语法总是${text}
下面是html:
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script>
</head>
<body>
<article id="img_list">
<ul>
<script id="imagesTmpl" type="text/x-jquery-tmpl">
<li>${text}<br/><br/></li>
</script>
</ul>
</article>
</body>
谢谢,效果很好!为我展示JSFIDLE提供了额外的要点。非常有用。你认为这可以使用API来完成吗?我尝试过:$.ajax({url:'?',data:data,success:callback});但这是空白的。我不明白为什么,它看起来似乎甚至没有尝试请求…$(document).ready(function(){$.getJSON(“?”,函数(数据){$.template(“imageTmpl”),$(“#imagesTmpl”);$.tmpl(“imageTmpl”,data.results).附录(“#img_列表”)});${text}
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script>
</head>
<body>
<article id="img_list">
<ul>
<script id="imagesTmpl" type="text/x-jquery-tmpl">
<li>${text}<br/><br/></li>
</script>
</ul>
</article>
</body>
$.getJSON('http://twitter.com/status/user_timeline/ladygaga.json?count=10&callback=?', function(data) {
$.template("imageTmpl", $("#imagesTmpl"));
$.tmpl("imageTmpl", data).appendTo("#img_list");
});