title: jQuery: How to get the data value after Ajax call
body: <p>I have read a few of the other questions on this and I still could not figure out how to get this to work.</p>
  
  <p>I have this function making the ajax call:</p>
  
  <pre><code>    function validateDataPoint(newDataPoint) {
          var $form = $(this).parents('form');
          var $formAction = $form.attr('action');
          var $validationResult;
  
          return $.ajax({
              type: "POST",
              url: "/DataPoints/ValidateNewDataPointBeforeSaving",
              data: newDataPoint
          });
  
          return $validationResult;
      }
  </code></pre>
  
  <p>And this is how I am calling it from within another function:</p>
  
  <pre><code>        var validationRequest = validateDataPoint(newDataPoint);
          validationResult = validationRequest.success(function (data) {
              return data.Urn;
          });
  </code></pre>
  
  <p>And then within the same function I want to test the value of validationResult since data.Urn will either have a string value of "Success" or "Failed" in relation to the processing that is completed on the server side.</p>
  
  <p>So here is the code below:</p>
  
  <pre><code>        //post the Json object to the server to validate and get the result
          var validationRequest = validateDataPoint(newDataPoint);
          validationResult = validationRequest.success(function (data) {
              return data.Urn;
          });
  
          //based on the result give the thumbs-up or thumbs-down
          if (validationResult == "Success") {
              resultFlag = "&lt;span class='badge badge-success'&gt;&lt;i class='icon-thumbs-up icon-white'&gt;&lt;/i&gt;&lt;/span&gt;";
          }
          else if (validationResult == "Failed") {
              resultFlag = "&lt;span class='badge badge-important'&gt;&lt;i class='icon-thumbs-down icon-white'&gt;&lt;/i&gt;&lt;/span&gt;";
          }
          else {
              resultFlag = "&lt;span class='badge badge-warning'&gt;&lt;/span&gt;";
          }
  </code></pre>
  
  <p><strong>So the question is</strong>...</p>
  
  <p>When I try to access the value of validationResult.responseText I get an undefined error. Basically I want to assign the value of data.Urn to validationResult but I just can't get this to work. If I alert(validationResult); I get [object Object] and then if I alert(validationResult); I get undefined.</p>
  
  <p>What am I missing here?</p>