title: Jquery ajax Check if there results are empty
body: <p>I am using the following code to pull in data from my database and plot points with google maps. What I want to do is something like, "if response=null, alert('empty')" but everytime I try to work that into this code, something just breaks. If anyone could offer any help that would be awesome. 
   Here is my code: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function ()
  
  {
      var radius3 = localStorage.getItem("radius2");
      var lat3 = localStorage.getItem("lat2");
      var long3 = localStorage.getItem("long2");
      var type2 = localStorage.getItem("type2");
      var citya = localStorage.getItem("city2");
      var rep2 = localStorage.getItem("rep2");
      var size2 = localStorage.getItem("size2");
      var status2 = localStorage.getItem("status2");
  
  
      $.ajax({
          url: 'http://examplecom/test/www/base_search.php',
          data: "city2=" + city2 + "&amp;rep2=" + rep2 + "&amp;status2=" + status2 + "&amp;size2=" + size2 + "&amp;type2=" + type2 + "&amp;long2=" + long2 + "&amp;lat2=" + lat2 + "&amp;radius2=" + radius2,
          type: 'post',
          dataType: 'json',
          success: function (data) {
              if (data) {
                  $.each(data, function (key, val) {
  
  
                      var lng = val['lng'];
                      var lat = val['lat'];
                      var id = val['id'];
                      var name = val['name'];
                      var address = val['address'];
                      var category = val['category'];
                      var city = val['city'];
                      var state = val['state'];
                      var rep = val['rep'];
                      var status = val['status'];
                      var size = val['size'];
                      $('div#google-map').gmap('addMarker', {
                          'position': new google.maps.LatLng(lat, lng),
                          'bounds': true,
                          'icon': 'images/hospital.png'
                      }).click(function () {
                          $('div#google-map').gmap('openInfoWindow', {
                              'backgroundColor': "rgb(32,32,32)",
                              'content': "&lt;table&gt;&lt;tr&gt;&lt;td&gt;Name:&lt;/td&gt;&lt;td&gt;" + name + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Address:&lt;/td&gt;&lt;td&gt;" + address + ", " + city + "&amp;nbsp;" + state + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Category:&lt;/td&gt;&lt;td&gt;" + category + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Rep:&lt;/td&gt;&lt;td&gt;" + rep + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Status:&lt;/td&gt;&lt;td&gt;" + status + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Size:&lt;/td&gt;&lt;td&gt;" + size + "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
                          }, this);
  
  
                      });
                  } else {
                      alert('hello');
                  }
                  }
              })
  
      }
      });
  
  
  })
  }
  
  
  
  &lt;/script&gt;
  </code></pre>