Nel tutorial che voglio proporvi oggi, vedremo come creare dei templates e interfacciarli con jQuery.
Il funzionamento è simile a quello di PHP. Sarà necessario posizionare le variabili all’interno del codice HTML e jQuery provvederà a “rimpiazzarle” con il loro valore.
-
Loading…
${tweet}
{{if geo}}
${geo}
{{/if}}
$.ajax({
type : ‘GET’,
dataType : ‘jsonp’,
url : ‘http://search.twitter.com/search.json?q=forrst’,
success : function(tweets) {
$(‘#load’).hide();
var twitter = $.map(tweets.results, function(obj, index) {
return {
username : obj.from_user,
tweet : obj.text,
userimg : obj.profile_image_url,
geo : obj.geo
};
});
$(‘#tweets’).tmpl(twitter).appendTo(‘#content’);
}
});
fonte: www.sastgroup.com » Vai al post originale






