How can I get the img error handler to work?

How can I get the img error handler to work?

It was suggested (here: http://stackoverflow.com/questions/17702123/is-there-a-way-to-programmatically-determine-that-an-image-link-is-bad) that I add the "$('img').error(function () {" code to deal with images which did not load by replacing it with a "no image available" image. However, it doesn't work. Why not? Is it in the wrong place? Is the code wrong? Or...???

  1.         $.getJSON('Content/NBCCJr.json', function (data) {
                $.each(data, function (i, dataPoint) {
                    if (IsYear(dataPoint.category)) {
                        htmlBuilder += '<div class=\"yearBanner\">' + dataPoint.category + '</div>';
                    } else { 
                        htmlBuilder += '<section class=\"wrapper\" ><a id=\"mainImage\" class=\"floatLeft\" href=\"' +
                            dataPoint.imghref + '\"' + ' target=\"_blank\"><img height=\"160\" width=\"107\" src=\"' +
                            dataPoint.imgsrc + '\"' +
                            dataPoint.imgalt + '></img></a>' +
                            '<div id=\"prizeCategory\" class=\"category\">' +
                            dataPoint.category +
                            '</div><br/><cite id=\"prizeTitle\" >' +
                            dataPoint.title +
                            '</cite><br/><div id=\"prizeArtist\" class=\"author\">' +
                            dataPoint.author +
                            '</div><br/>';
                        if (dataPoint.kindle.trim().length > 2) {
                            htmlBuilder += '<button><a href=\"' + Urlize(dataPoint.kindle) + '\"' +
                                ' target=\"_blank\">Kindle</a></button>';
                        }
                        if (dataPoint.hardbound.trim().length > 2) {
                            htmlBuilder += '<button><a href=\"' + Urlize(dataPoint.hardbound) + '\"' +
                                ' target=\"_blank\">Hardbound</a></button>';
                        }
                        if (dataPoint.paperback.trim().length > 2) {
                            htmlBuilder += '<button><a href=\"' + Urlize(dataPoint.paperback) + '\"' +
                                ' target=\"_blank\">Paperback</a></button>';
                        }
                        htmlBuilder += '</section>';
                        
                        // Doesn't work
                        $('img').error(function () {
                            $(this).attr("src", "Content/NoImageAvailable.png");
                        });
                    }
                }); //each