title: How to break out of Jquery for iteration
body: <p>I have a situation that I am using AJAX to call a page that returns a list of business locations to populate a Google map. My original goal was to display markers for locations whose radius touched the website visitor's location. </p>
  
  <p>Now I only need to know IF the website visitor is within the radius of any one of the locations returned by the ajax call. In the code below, you see a conditional statement "fink &lt;= rs.Records[recno].radius". What I am attempting to do is the first time that statement executes to true, set a cookie and/or call a function and exit the for loop. </p>
  
  <p>As a side question, a friend told me of something called grep (I think). Do I need to loop through an entire list to find if that condition is true? Meaning I know in mySQL I can just query something like "select * from locations where radius &lt; 50". So if my ajax returns 10,000 locations, all I need to know is my website visitor distance within the radius of any any of my locations? </p>
  
  <p>Thanks in advance for any help.</p>
  
  <pre><code>function distance(lat1, lon1, lat2, lon2) {
    var p = 0.017453292519943295; // Math.PI / 180
    var c = Math.cos;
    var a = 0.5 - c((lat2 - lat1) * p) / 2 +
      c(lat1 * p) * c(lat2 * p) *
      (1 - c((lon2 - lon1) * p)) / 2;
    return .62137119 * (12742 * Math.asin(Math.sqrt(a))); // 2 * R; R = 6371 km
  }
  
  
  function getMarkers(lat, lng, city, state) {
    $.ajax({
      url: '/getMarkers.asp?state=Nebraska',
      type: 'GET',
      dataType: 'text',
      error: function(xhr, status, errorstr) {
        console.log(errorstr); // just show error message in console if there was an error
      },
    }).done(function(response_obj) {
      console.log(response_obj);
      var rs = eval(response_obj);
      if (rs) { // has a non-null value
        var str = rs.RecordCount + " Users:&lt;br/&gt;";
  
        for (var recno = 0; recno &lt; rs.RecordCount; recno++) {
          fink = distance(&lt;%= session("uLat") %&gt;, &lt;%= session("uLng") %&gt;, rs.Records[recno].latitude, rs.Records[recno].longitude);
          if (fink &lt;= rs.Records[recno].radius) {
            $(".markers").append("&lt;li data-center='" + rs.Records[recno].latitude + ", " + rs.Records[recno].longitude + "' data-locale='" + recno + "' data-radius='" + rs.Records[recno].radius + "' data-location='" + rs.Records[recno].city + "'&gt;" + rs.Records[recno].street + "&lt;/li&gt;\n");
          }
        }
        initMap();
      } else {
        str = "No users found"
      }
    });
  }
  </code></pre>