javascript - How do you use js to insert json response into <a>xxxx</a> -


i trying implement "most recent" widget tumblr post. far, have been able grab top 5 recent posts using json post (http://stackoverflow.com/questions/5617378/how-to-display-a-link-to-my-latest-tumblr-post-using-javascript). want know how how insert {title} xxx link shows title of recent posts.

i thinking need use .append or .html, not sure how it. can me out.

javscript:

$.getjson('http://brianjsmith.tumblr.com/api/read/json?callback=?', function(response) {    $('#mylink').attr('href',response.posts[0].title); }); 

html:

<a id=#mylink>most recent post {title}</a> 

$('#mylink').attr('href',response.posts[0].url).text(response.posts[0].title); 

update: after check response, there no title property regular-title.

$('#mylink').attr('href',response.posts[0].url).text(response.posts[0]['regular-title']); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -