Skip to content

Instantly share code, notes, and snippets.

@Jalalhejazi
Created April 21, 2013 03:50
Show Gist options
  • Save Jalalhejazi/5428388 to your computer and use it in GitHub Desktop.
Save Jalalhejazi/5428388 to your computer and use it in GitHub Desktop.
AJAX: SuperWebApps.dk API get_recent_posts JSON
//http://jsfiddle.net/jalalhejazi/wWPs5/
$(function () {
//Add ul html to body
$('body').html('<ul id="results">');
//Call JSONP to CORS SuperWebApps.dk/API REST.get
$.ajax({
type: 'get',
dataType: "jsonp",
url: 'http://superwebapps.dk/api',
data: {
json: "get_recent_posts"
},
success: function (data) {
if (data) $.each(data.posts, function (k, v) {
console.log(v.title, v.url);
var link = "<a href='" + v.url + "'>" + v.title + "</a>"
$('ul#results').append('<li>' + link + '</li>');
});
}
});
});
@Jalalhejazi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment