Having followed a brief tutorial, I created this widget script to fetch posts from Blogger. Initially, it worked flawlessly without any errors in the theme that I designed it for. However, upon attempting to use the same code in a new template that I am currently working on, an error is thrown:
Uncaught TypeError: Cannot read property 'url' of undefined
No matter how much I rack my brain over it, I just can't seem to pinpoint why this is happening. To troubleshoot, I stripped away all other scripts, placed the code directly after the <body>
tag, and right before the closing </body>
tag.
I admit, scripting isn't my forte, and I originally embarked on creating this widget as a means to learn. It has been quite some time since I last tinkered with it. On scrutinizing the script now, I'm unable to identify the exact issue. Here's the snippet of the script:
<script type="text/javascript">
//<![CDATA[
function postGrabber(json) {
// Your magic here...
}
//]]>
</script>
<script type="text/javascript">
// Default settings for the widget
var imgSize = 96;
var summaryLength = 142;
var authorImgSize = 36;
var showImg = true;
var showTitle = true;
var showSummary = true;
var showDate = true;
var showAuthorImg = true;
var showCommentCount = true;
</script>
<script src="/feeds/posts/summary?orderby=published&max-results=5&alt=json-in-script&callback=postGrabber"></script>