title: Loading Message using jquery
body: <p>I have this loading message while my ajax call retrieves the data.  But I'm getting strange results.  Either the message appears and half way renders until ajax finishes or it doest appear at all leaving the user wondering what is wrong.  The reason I need a loading message is its about a 5-10 sec delay while the data is retrieved the dialog box is opened the map is drawn then the feature layer of the map is redrawn with labels.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>function loadData(v) 
  {       
      var reg = 1; 
      var vId = v;                       
      var d =
      {
          regionType: reg,
          varId: vId
      };
  
      //$("#loading").ajaxStart(function () {
      //    $(this).show();
      //}).ajaxStop(function () {
      //    $(this).hide();
      //});
  
      $("#loading").ajaxStart(function () {
          $(this).show();
      });
  
      $.ajax({
          type: "GET",
          url: WebRoot + "ws/bis.asmx/Data",
          data: d,
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (data) {                
  
              fipsData = data.d;
              openBox(d); 
              init(regType, varId);
  
              $("#loading").ajaxStop(function () {
                  $(this).hide();
              });
  
          } //ends success function
      });  //ends ajax call         
  }; //ends message
  </code></pre>