title: Why does my img error function fail?
body: <p>Some of the img elements that I am dynamically building may (do) fail. For those cases, I have some code I got from here:<a href="https://stackoverflow.com/questions/17702123/is-there-a-way-to-programmatically-determine-that-an-image-link-is-bad">Is there a way to programmatically determine that an image link is bad?</a> namely this:</p>
  
  <pre><code>    function getNatlBookCritics() {
          var htmlBuilder = '';
  
          // Doesn't do diddly-squat - wrong spot for it?
          $('img').error(function () {
              $(this).attr("src", "Content/NoImageAvailable.png");
          });
  
          $.getJSON('Content/NBCCJr.json', function (data) {
              $.each(data, function (i, dataPoint) {
      . . .
  </code></pre>
  
  <p>...but it's not working. Warum nicht?</p>
  
  <h2>UPDATE</h2>
  
  <p>With this code inside the .each portion of the $.getJSON() call:</p>
  
  <pre><code>var jObject = $('&lt;img src=\"' + dataPoint.imghref + '\"/&gt;');
  $(jObject).error(function () {
      $(this).attr("src", "Content/NoImageAvailable.jpg");
  });
  </code></pre>
  
  <p>...<em>all</em> of the images fail. dataPoint.imghref contains such values as:</p>
  
  <pre><code>http://www.amazon.com/exec/obidos/ASIN/B00655KLOY/garrphotgall-20
  </code></pre>
  
  <h2>UPDATE 2</h2>
  
  <p>In a nuts hell, I'm adding the "img src" like so:</p>
  
  <pre><code>function getNatlBookCritics() {
      var htmlBuilder = '';
      $.getJSON('Content/nbcc.json', function (data) {
          $.each(data, function (i, dataPoint) {
              if (IsYear(dataPoint.category)) {
                  htmlBuilder += '&lt;div class=\"yearBanner\"&gt;' + dataPoint.category + '&lt;/div&gt;';
              } else {
                  htmlBuilder += '&lt;section class=\"wrapper\" &gt;&lt;a id=\"mainImage\" class=\"floatLeft\" href=\"' +
                      dataPoint.imghref + '\"' + ' target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
                      dataPoint.imgsrc + '\"' +
                      dataPoint.imgalt + '&gt;&lt;/img&gt;&lt;/a&gt;' +
      . . .
                  htmlBuilder += '&lt;/section&gt;';
              }
      // this is where I had the img err code
          }); //each
          $('#BooksContent').append(htmlBuilder);
      });     //getNatlBookCritics
  </code></pre>
  
  <p>...so as you can see the img is getting added to the DOM; maybe the fact that I've got height and width properties with my img are the problem...</p>
  
  <h2>UPDATE 3</h2>
  
  <p>ManMohan Vyas: Do you mean like so:</p>
  
  <pre><code>}); //each
          $('#BooksContent').append(htmlBuilder).
      find("img").error(function(){ 
          $(this).attr("src", "Content/NoImageAvailable.png");
      });
      });     //getJSON()
  </code></pre>
  
  <p>?</p>
  
  <h2>UPDATE 4</h2>
  
  <p>This:</p>
  
  <pre><code>var jObject = $(htmlBuilder);
  jObject.find("img").error(function () {
      $(this).attr("src", "Content/NoImageAvailable.png");
  });
  $('#BooksContent').append(jObject);
  </code></pre>
  
  <p>...didn't work.</p>
  
  <p>And FWIW, changing this:</p>
  
  <pre><code>$('#BooksContent').html('');
  </code></pre>
  
  <p>. . .
      $('#BooksContent').append(htmlBuilder);</p>
  
  <p>...to this:</p>
  
  <p>$('#BooksContent').replaceWith(htmlBuilder);</p>
  
  <p>...didn't work well (the right stuff populated, but the formatting got all messed up (instead of a solid black background, each section had a black background, but the overall background was silver).</p>
  
  <h2>UPDATE 5</h2>
  
  <p>I just thought of something that may be causing my problem: the images that I'm attempting to show are all jpgs, but the "Image Not Available" image is a png. Does that make a difference? Is that possibly what is causing the rendering engine to get confused? If so, I'll just save the fallback img as a jpg...</p>
  
  <h2>UPDATE 6</h2>
  
  <p>Nope, these last two attempts didn't work either. I tried Joseph Myers idea, then Prestauls, as I changed this:</p>
  
  <pre><code>dataPoint.imghref + '\"' + ' onerror=\"imgError(this);\" target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
  dataPoint.imgsrc + '\"' +
  </code></pre>
  
  <p>..to this:</p>
  
  <pre><code>dataPoint.imgsrc + '\" onerror=\"imgError(this);\"' +
  dataPoint.imgalt + '&gt;&lt;/img&gt;&lt;/a&gt;' +
  </code></pre>
  
  <p>...and no difference. I asked this on the jQuery forum a bit ago: I'm grasping at straws here, but I wonder if having mismatched jQuery/jQueryUI versions could be the problem? In order to support older browsers, I'm still using jQuery 1.9.1, but am on the "bleeding edge" as regards jQueryUI with version 1.10.3.</p>
  
  <h2>UPDATE 7</h2>
  
  <p>Okay, here's <em>all</em> the pertinent code (some redundant and moot code that will be refactored out has been elided to comply with SO's length limits). The (static) CSS shouldn't matter, right? The only other "code" is Web.config and things of that nature, so none of that should be having an effect on why I can't get the fallback images to display.</p>
  
  <p>A lot of my failed attempts to get NoImageAvailable.png to display are commented out.</p>
  
  <pre><code>@{
      Layout = "~/_SiteLayout.cshtml";
      Page.Title = "My Next Winner";
  }
  &lt;div id="tabs" class="content-wrapper"&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="#tab-Books"&gt;Books&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#tab-Movies"&gt;Movies&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#tab-Music"&gt;Music&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;div id="tab-Books"&gt;
          &lt;select id="bookDropDown"&gt;
              &lt;option value="Pulitzer"&gt;Pulitzer&lt;/option&gt;
              &lt;option value="NBCC"&gt;National Book Critics Circle&lt;/option&gt;
              &lt;option value="NBA"&gt;National Book Awards&lt;/option&gt;
              &lt;option value="NOBA"&gt;National Outdoors Book Awards&lt;/option&gt;
          &lt;/select&gt;
          &lt;div id="BooksContent" class="clearfix"&gt;Content in Books tab&lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="tab-Movies"&gt;
  </code></pre>
  
  <p>. . .        
          
  . . .        
      </p>
  
  <pre><code>&lt;script&gt;
      $.ajaxSetup({ cache: false });
      var currentBookSelection = ''; 
      var currentMovieSelection = '';
      var currentMusicSelection = '';
  
      function imgError(image) {
          image.onerror = "";
          image.src = "Content/NoImageAvailable.png"; 
          return true;
      }
  
      // BOOKS
  // TODO: Refactor: just have one "getBooks()" function, passing in the name of the json file
      function getNatlBookCritics() {
          var htmlBuilder = '';
  
          $.getJSON('Content/nbcc.json', function (data) {
              $.each(data, function (i, dataPoint) {
                  if (IsYear(dataPoint.category)) {
                      htmlBuilder += '&lt;div class=\"yearBanner\"&gt;' + dataPoint.category + '&lt;/div&gt;';
                  } else { // see snippet at top of unit for dealing with landscape-oriented books (such as some children's books) to change height and width of img
                      htmlBuilder += '&lt;section class=\"wrapper\" &gt;&lt;a id=\"mainImage\" class=\"floatLeft\" href=\"' +
                          dataPoint.imghref + '\"' + ' target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
                          //dataPoint.imghref + '\"' + ' onerror=\"imgError(this);\" target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
                          //dataPoint.imgsrc + '\" onerror=\"imgError(this);\"' +
                          dataPoint.imgsrc + '\"' +
                          dataPoint.imgalt + '&gt;&lt;/img&gt;&lt;/a&gt;' +
                          '&lt;div id=\"prizeCategory\" class=\"category\"&gt;' +
                          dataPoint.category +
                          '&lt;/div&gt;&lt;br/&gt;&lt;cite id=\"prizeTitle\" &gt;' +
                          dataPoint.title +
                          '&lt;/cite&gt;&lt;br/&gt;&lt;div id=\"prizeArtist\" class=\"author\"&gt;' +
                          dataPoint.author +
                          '&lt;/div&gt;&lt;br/&gt;';
                      if (dataPoint.kindle.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.kindle) + '\"' +
                              ' target=\"_blank\"&gt;Kindle&lt;/a&gt;&lt;/button&gt;';
                      }
                      if (dataPoint.paperback.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.paperback) + '\"' +
                              ' target=\"_blank\"&gt;Paperback&lt;/a&gt;&lt;/button&gt;';
                      }
                      if (dataPoint.hardbound.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.hardbound) + '\"' +
                              ' target=\"_blank\"&gt;Hardcover&lt;/a&gt;&lt;/button&gt;';
                      }
                      htmlBuilder += '&lt;/section&gt;';
  
                      //// Doesn't work
                      //$('img').error(function () {
                      //    $(this).attr("src", "Content/NoImageAvailable.png");
                      //});
                      // When get answer, try this: &lt;-- they all fail with this
                      //var jObject = $('&lt;img src=\"' + dataPoint.imghref + '\"/&gt;');
                      //var jObject = $('&lt;img src=' + dataPoint.imghref + ' /&gt;');
                      //$(jObject).error(function () {
                      //    $(this).attr("src", "Content/NoImageAvailable.jpg");
                      //});
                  }
              }); //each
              //var jObject = $(htmlBuilder).find('img').error(function () {
              //    $(this).attr("src", "Content/NoImageAvailable.png")
              //});
  
              //$("#BooksContent").html(jObject);
              //var jObject = $(htmlBuilder);
              //jObject.find("img").error(function () {
              //    $(this).attr("src", "Content/NoImageAvailable.png");
              //});
              //$('#BooksContent').append(jObject);
  
              // 7/23
              //imageError = function (it) {
              //    $(it).attr("src", "Content/NoImageAvailable.png");
              //};
              //htmlBuilder = htmlBuilder.replace(/&lt;img/g, '&lt;img onerror="imageError(this)"');
              //var jObject = $(htmlBuilder);
  
              //$("#BooksContent").html(jObject);
              // &lt;/ 7/23
  
              //$('#BooksContent').html('');
              //$('#BooksContent').append(htmlBuilder);
  
              ////try this 7/24/2013
              //var $jObject = $('&lt;img&gt;');
              //$jObject.error(function () { //$jObject is already a jquery object, don't wrap it again
              //    $(this).attr("src", "Content/NoImageAvailable.jpg");
              //}).attr('src', dataPoint.imghref);
              //&lt;/try this 7/24/2013
  
              //$('#BooksContent').html(htmlBuilder);
              $('#BooksContent').html(htmlBuilder).
                   find('img, button').click(function (evt) {
                       $(this).css('border', '1px solid red')
                       //evt.preventDefault();
                       //find('img').error(function() {
                       //    this.src = "/Content/NoImageAvailable.png"
                       //})
                   });
  
              //$('#BooksContent').replaceWith(htmlBuilder);
                  //.find('img').error(function() {
                  //    this.src = "Content/NoImageAvailable.png"
                  //    //this.src = "http://www.gravatar.com/avatar/317f4b62da2b0186feac9b6209793505?s=80&amp;d=http%3A%2F%2Fimg.zohostatic.com%2Fdiscussions%2Fv1%2Fimages%2FdefaultPhoto.png";
                  //});
              $('#BooksContent').css('background-color', 'black');
              $('button').button();
          }); //getJSONnbcc
          $largest = 0;
          $(".wrapper").each(function () {
              if ($(this).height() &gt; $largest) {
                  $largest = $(this).height();
              }
          });
          $(".wrapper").css("height", $largest);
      }   // getNatlBookCritics()
  
      function getPulitzers() {
          // Since pulitzers will be the one that shows when site first opens, added rel="nofollow"
          // in each href; in this way only this method differs from the other "getX" book methods
          var htmlBuilder = '';
  
          $.getJSON('Content/pulitzers2.json', function (data) {
              $.each(data, function (i, dataPoint) {
                  if (IsYear(dataPoint.category)) {
                      htmlBuilder += '&lt;div class=\"yearBanner\"&gt;' + dataPoint.category + '&lt;/div&gt;';
                  } else { // see snippet at top of unit for dealing with landscape-oriented books (such as some children's books) to change height and width of img
                      htmlBuilder += '&lt;section class=\"wrapper\" &gt;&lt;a id=\"mainImage\" class=\"floatLeft\" href=\"' +
                          dataPoint.imghref + '\"' + ' target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
                          dataPoint.imgsrc + '\"' +
                          dataPoint.imgalt + '&gt;&lt;/img&gt;&lt;/a&gt;' +
                          '&lt;div id=\"prizeCategory\" class=\"category\"&gt;' +
                          dataPoint.category +
                          '&lt;/div&gt;&lt;br/&gt;&lt;cite id=\"prizeTitle\" &gt;' +
                          dataPoint.title +
                          '&lt;/cite&gt;&lt;br/&gt;&lt;div id=\"prizeArtist\" class=\"author\"&gt;' +
                          dataPoint.author +
                          '&lt;/div&gt;&lt;br/&gt;';
                      if (dataPoint.kindle.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.kindle) + '\"' +
                              ' target=\"_blank\" rel=\"nofollow\" &gt;Kindle&lt;/a&gt;&lt;/button&gt;';
                      }
                      if (dataPoint.hardbound.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.hardbound) + '\"' +
                              ' target=\"_blank\" rel=\"nofollow\" &gt;Hardcover&lt;/a&gt;&lt;/button&gt;';
                      }
                      if (dataPoint.paperback.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.paperback) + '\"' +
                              ' target=\"_blank\" rel=\"nofollow\" &gt;Paperback&lt;/a&gt;&lt;/button&gt;';
                      }
                      htmlBuilder += '&lt;/section&gt;';
                  }
              }); //each
              $('#BooksContent').html(htmlBuilder).
       find('img, button').click(function (evt) {
           $(this).css('border', '1px solid red')
       });
  
              $('#BooksContent').css('background-color', 'black');
              $('button').button();
          }); //getPulitzers
          $largest = 0;
          $(".wrapper").each(function () {
              if ($(this).height() &gt; $largest) {
                  $largest = $(this).height();
              }
          });
          $(".wrapper").css("height", $largest);
          // This is not working; axed a question on the jQuery forum
          $('img, button').click(function (evt) {
              $(this).css('border', '5px solid green');
              evt.preventDefault();
          });
          // added this 7/24/2013 - does nothing
          //$(function () {
          //    $('a').click(function () {
          //        open(this.href, 'NewWin', 'toolbar=yes');
          //        self.focus();
          //        return false;
          //    });
          //});
      } // getPulitzers()
  
      function getNatlBook() {
  </code></pre>
  
  <p>. . .        } // getNatlBook()</p>
  
  <pre><code>    function getNOBA() {
          // load bookContents using getJSON
      }
  
      // MOVIES
      // Movies differ from books and music in that some of the awards do not always have a person as winner - just the movie
      // So we have to check for that and conditionally add that bit of html (what corresponds to author in books and
      // artist in music)
      function getMovies(pathToJsonFile) {
          var htmlBuilder = '';
  
          $.getJSON(pathToJsonFile, function (data) {
              // I tried renaming the above to nbcc.json, but it won't work with that name...?!? $.getJSON('Content/nbcc.json', function (data) {
              $.each(data, function (i, dataPoint) {
                  if (IsYear(dataPoint.category)) {
                      htmlBuilder += '&lt;div class=\"yearBanner\"&gt;' + dataPoint.category + '&lt;/div&gt;';
                  } else { // see snippet at top of unit for dealing with landscape-oriented books (such as some children's books) to change height and width of img
                      htmlBuilder += '&lt;section class=\"wrapper\" &gt;&lt;a id=\"mainImage\" class=\"floatLeft\" href=\"' +
                          dataPoint.imghref + '\"' + ' target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
                          dataPoint.imgsrc + '\"' +
                          dataPoint.imgalt + '&gt;&lt;/img&gt;&lt;/a&gt;' +
                          '&lt;div id=\"prizeCategory\" class=\"category\"&gt;' +
                          dataPoint.category +
                          '&lt;/div&gt;&lt;br/&gt;&lt;cite id=\"prizeTitle\" &gt;' +
                          dataPoint.film +
                          '&lt;/cite&gt;&lt;br/&gt;';
                      if (dataPoint.person.trim().length &gt; 2) {
                          htmlBuilder += '&lt;div id=\"prizeArtist\" class=\"person\"&gt;' + dataPoint.person + '&lt;/div&gt;&lt;br/&gt;';
                      }
                      if (dataPoint.bluray.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.bluray) + '\"' +
                              ' target=\"_blank\" &gt;BluRay&lt;/a&gt;&lt;/button&gt;';
                      }
                      if (dataPoint.dvd.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.dvd) + '\"' +
                              ' target=\"_blank\" &gt;DVD&lt;/a&gt;&lt;/button&gt;';
                      }
                      htmlBuilder += '&lt;/section&gt;';
                  }
              }); //each
              $('#MoviesContent').html(htmlBuilder).
                   find('img, button').click(function (evt) {
                       $(this).css('border', '1px solid silver')
                   });
              $('#MoviesContent').css('background-color', 'black');
              $('button').button();
              //console.log(htmlBuilder); &lt;-- may want this for response to click on tab when movie tab is selected
          }); //getOscars
          $largest = 0;
          $(".wrapper").each(function () {
              if ($(this).height() &gt; $largest) {
                  $largest = $(this).height();
              }
          });
          $(".wrapper").css("height", $largest);
      }
  
      // MUSIC 
      // "work" is used for "album or song or recording or performance"
  //TODO: Make this a generic "Music" function a la Movies above
      function getGrammies() {
          var htmlBuilder = '';
  
          $.getJSON('Content/grammies.json', function (data) {
              $.each(data, function (i, dataPoint) {
                  if (IsYear(dataPoint.category)) {
                      htmlBuilder += '&lt;div class=\"yearBanner\"&gt;' + dataPoint.category + '&lt;/div&gt;';
                  } else { // see snippet at top of unit for dealing with landscape-oriented books (such as some children's books) to change height and width of img
                      htmlBuilder += '&lt;section class=\"wrapper\" &gt;&lt;a id=\"mainImage\" class=\"floatLeft\" href=\"' +
                          dataPoint.imghref + '\"' + ' target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
                          dataPoint.imgsrc + '\"' +
                          dataPoint.imgalt + '&gt;&lt;/img&gt;&lt;/a&gt;' +
                          '&lt;div id=\"prizeCategory\" class=\"category\"&gt;' +
                          dataPoint.category +
                          '&lt;/div&gt;&lt;br/&gt;&lt;cite id=\"prizeTitle\" &gt;' +
                          dataPoint.work +
                          '&lt;/cite&gt;&lt;br/&gt;&lt;div id=\"prizeArtist\" class=\"work\"&gt;' +
                          dataPoint.artist +
                          '&lt;/div&gt;&lt;br/&gt;';
                      if (dataPoint.mp3.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.mp3) + '\"' +
                              ' target=\"_blank\"&gt;mp3&lt;/a&gt;&lt;/button&gt;';
                      }
                      if (dataPoint.dvd.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.dvd) + '\"' +
                              ' target=\"_blank\"&gt;DVD&lt;/a&gt;&lt;/button&gt;';
                      }
                      if (dataPoint.vinyl.trim().length &gt; 2) {
                          htmlBuilder += '&lt;button&gt;&lt;a href=\"' + Urlify(dataPoint.vinyl) + '\"' +
                              ' target=\"_blank\"&gt;Vinyl&lt;/a&gt;&lt;/button&gt;';
                      }
                      htmlBuilder += '&lt;/section&gt;';
  
                      //// Doesn't work
                      //$('img').error(function () {
                      //    $(this).attr("src", "Content/NoImageAvailable.png");
                      //});
                  }
              }); //each
              $('#MusicContent').html(htmlBuilder).
       find('img, button').click(function (evt) {
           $(this).css('border', '1px solid gold')
       });
              $('#MusicContent').css('background-color', 'black');
              $('button').button();
          }); //getJSONMusic
          $largest = 0;
          $(".wrapper").each(function () {
              if ($(this).height() &gt; $largest) {
                  $largest = $(this).height();
              }
          });
          $(".wrapper").css("height", $largest);
      }
  
      function configLoading() {
          $('#lblLoading').show();
  // TODO: Not working for some reason - the configLoaded never sets them back to enabled...
          //$('bookDropDown').Attr('disabled', true);
          //$('moviesDropDown').Attr('disabled', true);
          //$('musicDropDown').Attr('disabled', true);
      }
  
      function configLoaded() {
          $('#lblLoading').hide();
          //$('bookDropDown').Attr('disabled', false);
          //$('moviesDropDown').Attr('disabled', false);
          //$('musicDropDown').Attr('disabled', false);
      }
  
          $(document).ready(function () {
              $('#tabs').tabs({
                  beforeActivate: function (event, ui) {
                      // Pulitzers is loaded at first; any time the books tab is clicked, something will already be there
                      if (ui.newTab.index() == 1) {
                          moviesContent = $('#MoviesContent').html();
                          if (moviesContent == 'Content in Movies tab') {
                              // TODO: When it's ready, uncomment this: getOscars();
                          }
                      }
                      else if (ui.newTab.index() == 2) {
                          musicContent = $('#MusicContent').html();
                          if (musicContent == 'Content in Music tab') {
                              // TODO: When it's ready, uncomment this: getGrammies();
                          }
                      }
                  }
              });
  
              $('body').on('error', 'img', function (e) {
                  $(e.currentTarget).attr("src", "Content/NoImageAvailable.png");
              });
  
              // This makes the external hrefs / targets "pop up"; I don't think I want that...
              //$('body').on('click', 'a', function () {
              //    open(this.href, 'NewWin', 'toolbar=yes')
              //    self.focus();
              //    return false;
              //});
  
              // Books tab is default view; load the default list (Pulitzer); the other two default lists (oscars and grammies)
              // will load the first time the user selects the corresponding tab (see beforeActivate() above)
              getPulitzers();
              currentBookSelection = "Pulitzer";
              configLoaded();
  
              $('#bookDropDown').change(function () {
                  // TODO: May want to keep track of when in loading mode, and if so, exit/return
                  configLoading();
                  $('#body').removeClass('bronzeBackground silverBackground goldBackground').addClass('bronzeBackground');
                  var sel = this.value;
                  if ((sel == "NBCC") &amp;&amp; (currentBookSelection != "NBCC")) {
                      getNatlBookCritics();
                      currentBookSelection = "NBCC";
                  }
                  else if ((sel == "NBA") &amp;&amp; (currentBookSelection != "NBA")) {
                      getNatlBook();
                      currentBookSelection = "NBA";
                  }
                  else if ((sel == "NOBA") &amp;&amp; (currentBookSelection != "NOBA")) {
                      getNOBA();
                      currentBookSelection = "NOBA";
                  }
                  else if ((sel == "Pulitzer") &amp;&amp; (currentBookSelection != "Pulitzer")) {
                      getPulitzers();
                      currentBookSelection = "Pulitzer";
                  }
                  configLoaded();
              }); //bookDropDown
  
              $('#moviesDropDown').change(function () {
                  configLoading();
                  $('#body').removeClass('bronzeBackground silverBackground goldBackground').addClass('silverBackground');
                  var sel = this.value;
                  if ((sel == "Oscars") &amp;&amp; (currentMovieSelection != "Oscars")) {
                      currentMovieSelection = "Oscars";
                      getMovies('Content/oscars.json');
                  }
                  else if ((sel == "GoldenGlobe") &amp;&amp; (currentMovieSelection != "GoldenGlobe")) {
                      currentMovieSelection = "GoldenGlobe";
                      getMovies('Content/goldenglobe.json');
                  }
                  else if ((sel == "Cannes") &amp;&amp; (currentMovieSelection != "Cannes")) {
                      currentMovieSelection = "Cannes";
                      getMovies('Content/cannes.json');
                  }
                  else if ((sel == "Sundance") &amp;&amp; (currentMovieSelection != "Sundance")) {
                      currentMovieSelection = "Sundance";
                      getMovies('Content/sundance.json');
                  }
                  configLoaded();
              }); //moviesDropDown
  
              $('#musicDropDown').change(function () {
                  configLoading();
                  $('#body').removeClass('bronzeBackground silverBackground goldBackground').addClass('goldBackground');
                  var sel = this.value;
                  if ((sel == "Grammies") &amp;&amp; (currentMusicSelection != "Grammies")) {
                      currentMusicSelection = "Grammies";
                      getGrammies();
                  }
                  else if ((sel == "AMA") &amp;&amp; (currentMusicSelection != "AMA")) {
                      currentMusicSelection = "AMA";
                      getAMA();
                  }
                  else if ((sel == "CMA") &amp;&amp; (currentMusicSelection != "CMA")) {
                      currentMusicSelection = "CMA";
                      getCMA();
                  }
                  else if ((sel == "Indies") &amp;&amp; (currentMusicSelection != "Indies")) {
                      currentMusicSelection = "Indies";
                      getIndies();
                  }
                  configLoaded();
              }); //musicDropDown
  
              // added 7/24/2013, changed nothing
              //$(function() {
              //    $('a').click(function() {
              //        open(this.href, 'NewWin', 'toolbar=yes');
              //        self.focus();
              //        return false;
              //    });
              //});
  
          }); //ready
  &lt;/script&gt;
  </code></pre>
  
  <h2>UPDATE 8</h2>
  
  <p>barvaz's answer also does not work for me; maybe I'm doing it wrong? Based on his answer, this is what I added:</p>
  
  <p>CSS</p>
  
  <pre><code>.noImg {
    background:url(~/Content/NoImageAvailable.png);    
  }
  </code></pre>
  
  <p>jQuery</p>
  
  <p>0) Added this within the ready handler:</p>
  
  <pre><code>replaceEmptyImage = function ($img) {
      $img.parent().addClass('noImg');
      $img.remove();
  };
  </code></pre>
  
  <p>1) Changed this line:</p>
  
  <pre><code>dataPoint.imghref + '\"' + ' target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" src=\"' +
  </code></pre>
  
  <p>...to this:</p>
  
  <pre><code>dataPoint.imghref + '\"' + ' target=\"_blank\"&gt;&lt;img height=\"160\" width=\"107\" onerror=\"replaceEmptyImage($(this))\" src=\"' +
  </code></pre>
  
  <h2>UPDATE 9</h2>
  
  <p>Here's what it looks like (the image "block" or "object" is there, it's just that it's black/blank):</p>
  
  <p><img src="https://i.stack.imgur.com/Wbkqn.png" alt="enter image description here"></p>
  
  <p>BTW, The Travels of Jamie McPheeters is an awesome book at any rate, but perhaps especially to read to your kids (any age, but perhaps pre-teen is optimal).</p>