title: Creating error handling in jQuery
body: <p>I am trying to create an error message from jquery for my document.</p>
  
  <p>I have populated a <code>&lt;select&gt;</code> menu with JSON data, they link to external HTML files to display weather for their Location, what I need is for an error message to appear if there is no HTML file for the option.</p>
  
  <p>For example the locations are London, New York, Paris and Rome, all except Rome have an HTML file that has weather data in it and displays fine but when Rome is selected...Nothing happens! and when Rome is selected after another location has been selected it stays on the current data!</p>
  
  <p>I am using jQuery to pull the data etc. its my gut feeling that it needs an <code>if()</code> statement but I'm not sure of the conditions of the statement!</p>
  
  <p>My jQuery code is here...</p>
  
  <pre><code>$(document).ready(function () {
  
      // The below function pulls in the data from the external JSON file
  
      $.getJSON('json/destinations.json', function (data) {
  
          // attaches it to a variable
          var destinations = data.Destinations;
  
          $(destinations).each(function (id, destination) {
              $('#destinations').append('&lt;option value="' + destination.destinationID + '"&gt;' + destination.destinationName + '&lt;/option&gt;');
          });
  
          $("#destinations").change(function () {
              $('#weatherForecasts').load('raw_html/' + $(this).val() + '_weather.html .ngtable', function () {
                  $('#weatherForecasts').show("slow");
              });
          });
  
      });
  
      // Hide statements for our extra fields and also the weather forecast DIV
      $('#weatherForecasts').hide();
      $('#extraFields').hide();
      $('.errorMessage').hide();
  
      // Function that allows us to see the extraFields when a radio button is checked!
      $("input[name='survey1']").change(function () {
          $("#extraFields").show("slow");
      });
      $("input[name='survey1']:checked").change(); //trigger correct state onload
  
  });
  </code></pre>