title: How to check if a ResultSet of an AJAX call using JQuery has value
body: <p>I am Using iQuery to make AJAX Calls to the server and return a set of values. The Values returned are dynamic. The Result count being dynamic I am not able to look the result set and assign values to HTML Elements to show in Web Page. </p>
  
  <p>Kindly advice how I could look if there is a value in the result set and use the same in my system. The Maximum count in result set is 16 and i have manually assigned values in the Script.</p>
  
  <p><em>Calling the AJAX Method in the document ready of my Web Page.</em></p>
  
  <pre><code>$(document).ready(function () {
      CallAJAX('../Forms/Send.aspx/refreshDash', '', 'FillMethod', 'FillMethodE');
  });
  </code></pre>
  
  <p><em>AJAX Call Definition</em></p>
  
  <pre><code>function CallAJAX(ServerMethod, Parameters, SuccessMethod, ErrorMethod) {
      $.ajax({
          type: "POST",
          url: ServerMethod,
          data: Parameters,
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          error: function (xhr, status, errorThrown) {
              Error = xhr; Result.d.ResultSet[0].TRCOUNT
              eval(ErrorMethod + "()");
          },
          success: function (msg) {
              Result = msg;
              var rr = SuccessMethod + "();";
              eval(rr);
          }
      });
  }
  </code></pre>
  
  <p><em>Using Two jQuery Functions to Show Details and prompt Message when error is Raised. Note Error Function is not Shown.</em></p>
  
  <pre><code>function FillMethod() {
      if ($.isEmptyObject(Result.d.ResultSet)) {
  
      }
      else {
  
          $('[id$=lblCode1]').html(Result.d.ResultSet[0].DASH_NAME);
          $('[id$=lblNot1]').html(Result.d.ResultSet[0].TRCOUNT);
  
          $('[id$=lblCode2]').html(Result.d.ResultSet[1].DASH_NAME);
          $('[id$=lblNot2]').html(Result.d.ResultSet[1].TRCOUNT);
  
  
          $('[id$=lblCode3]').html(Result.d.ResultSet[2].DASH_NAME);
          $('[id$=lblNot3]').html(Result.d.ResultSet[2].TRCOUNT);
  
          $('[id$=lblCode4]').html(Result.d.ResultSet[3].DASH_NAME);
          $('[id$=lblNot4]').html(Result.d.ResultSet[3].TRCOUNT);
  
          $('[id$=lblCode5]').html(Result.d.ResultSet[4].DASH_NAME);
          $('[id$=lblNot5]').html(Result.d.ResultSet[4].TRCOUNT);
  
          $('[id$=lblCode6]').html(Result.d.ResultSet[5].DASH_NAME);
          $('[id$=lblNot6]').html(Result.d.ResultSet[5].TRCOUNT);
  
  
          $('[id$=lblCode7]').html(Result.d.ResultSet[6].DASH_NAME);
          $('[id$=lblNot7]').html(Result.d.ResultSet[6].TRCOUNT);
  
          $('[id$=lblCode8]').html(Result.d.ResultSet[7].DASH_NAME);
          $('[id$=lblNot8]').html(Result.d.ResultSet[7].TRCOUNT);
  
  
          $('[id$=lblCode9]').html(Result.d.ResultSet[8].DASH_NAME);
          $('[id$=lblNot9]').html(Result.d.ResultSet[8].TRCOUNT);
  
          $('[id$=lblCode10]').html(Result.d.ResultSet[9].DASH_NAME);
          $('[id$=lblNot10]').html(Result.d.ResultSet[9].TRCOUNT);
  
  
          $('[id$=lblCode11]').html(Result.d.ResultSet[10].DASH_NAME);
          $('[id$=lblNot11]').html(Result.d.ResultSet[10].TRCOUNT);
  
          $('[id$=lblCode12]').html(Result.d.ResultSet[11].DASH_NAME);
          $('[id$=lblNot12]').html(Result.d.ResultSet[11].TRCOUNT);
  
          $('[id$=lblCode13]').html(Result.d.ResultSet[12].DASH_NAME);
          $('[id$=lblNot13]').html(Result.d.ResultSet[12].TRCOUNT);
  
          $('[id$=lblCode14]').html(Result.d.ResultSet[13].DASH_NAME);
          $('[id$=lblNot14]').html(Result.d.ResultSet[13].TRCOUNT);
  
  
          $('[id$=lblCode15]').html(Result.d.ResultSet[14].DASH_NAME);
          $('[id$=lblNot15]').html(Result.d.ResultSet[14].TRCOUNT);
  
          $('[id$=lblCode16]').html(Result.d.ResultSet[15].DASH_NAME);
          $('[id$=lblNot16]').html(Result.d.ResultSet[15].TRCOUNT);
      }
  };
  function FillMethodE() {
  
  
  }
  </code></pre>
  
  <p>Issue is being raised in the FillMethod function when only Result.d.ResultSet[0].DASH_NAME has a valid value and the following indexes does not have any values. 
  <strong>NOTE:</strong> Results are returned in pairs, if DASH_NAME is available then TRCOUNT will also be available for the same index.</p>
  
  <p><img src="https://i.stack.imgur.com/yYuU6.png" alt="Dynamic Result 1">
  <img src="https://i.stack.imgur.com/ZbWaa.png" alt="Dynamic Result 2"></p>
  
  <p>All I need to do is irrespective of the result count i need to display in the labels in order values from the result set dynamically. Here are are two sets of result sets which could be obtained.</p>