Skip to content

Instantly share code, notes, and snippets.

@torounit
Last active December 11, 2015 06:22
Show Gist options
  • Save torounit/1138796a3c5a6fccaaad to your computer and use it in GitHub Desktop.
Save torounit/1138796a3c5a6fccaaad to your computer and use it in GitHub Desktop.
WP REST API で JSONP
var list = $('<ul />');
var request = $.getJSON('http://torounit.com/wp-json/wp/v2/posts?_jsonp=?')
request.done(function(data){
data.forEach(function(row){
var item = $('<li>');
var content = $('<a />').text(row.title.rendered).attr('href', row.link);
item.append(content);
list.append(item);
});
$('body').append(list);
}).fail(function(){
console.log('fail');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment