I'm trying to fetch the last 3 blog posts with the draft = false for my system via jQuery json and following some tutorials if found online but without luck, and with the following keys:
"slug"
"updated"
"title"
"content"
"draft = false"
Here is the json output
{
"posts":[
{
"Blog":{
"id":"1252",
"client_id":"1432",
"slug":"my-blog-slug",
"last_updated_by":"614",
"draft":false,
"created":"2014-09-17 11:18:39",
"updated":"2014-09-17 11:18:39",
"locale":"isl",
"title":"This is the blog title",
"content":"<p>My excellent content.<\/p>",
"author":"John Doe"
},
"UpdatedBy":{
"id":"614",
"name":"John Doe"
}
}
]
}
My current script is below, but i'm pretty sure that i'm doing a lot of things wrong.
<script>
$(document).ready(function() {
$.ajax({
url: "blogs.json",
dataType: "text",
success: function(data) {
var json = $.parseJSON(data);
$('#results').html('Title: ' + json.created + '<br />Description: ' + json.content);
}
});
});
</script>
<div id="results"></div>
Any help would be so much appreciated.