I want to feed this JSON URL to another site
http://naturetrek.co.uk/blog/api/get_recent_posts/
But the problem is that because of the initial three <p>
tags its not valid JSON, you can check this in here...
if u remove these 3 tags, it becomes valid.
We cant change the JSON string output from the Naturetrek Blog.
In our own code we use the following....
<h2>Naturetrek BLOG</h2>
<div id="ntblog"></div>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var blogURL = "http://naturetrek.co.uk/blog/api/get_recent_posts/";
$.getJSON(blogURL, function(info) {
alert("here");
var output = info.status;
/*
for (var i = 0; i <= info.posts.length - 1; i++) {
output += '<li>' +
'<a href = "' + info.posts[i].url +
'">' + info.posts[i].title + '</a></li>';
}
*/
var ntblog = document.getElementById('ntblog');
ntblog.innerHTML = output;
});
});
</script>
The alert never gets called, because the JSON is invalid JSON. MY QUESTION IS -- IS THERE A WAY TO PREPARSE THE JSON TO REMOVE THE THREE <p>
TAGS, SOMEHOW? OR ANOTHER WAY U CAN THINK OF?