title: Issue with getting value from $.ajax inside a $.when
body: <p>Hey guys I have the following code:</p>
  
  <pre><code>function runATF(){
          var urlatf = '/pcg/ATF/updateATF_window.php';
          var tagatf = $("#insider_dialog");
  
          var promise1 = showUrlInDialogATF(urlatf);
          var promise2 = sendUpdateATFwindow();
  
          $.when(promise1, promise2).done(function(data1, data2) {
  
              tagatf.html(data1[0]).dialog({
                width: '100%',
                modal: true
              }).dialog('open');
             //$('.updaterATF_outerbody').text(data2[0].atfName),
             //$('.updaterATF_outerbody').text(data2[0].atfAmount)
             //console.log(data2[1]);
            alert(data2[0].text(atfName));
                alert(data2[0].text(atfAmount));
          });
      }
  </code></pre>
  
  <p>The part I need you to look at it the <code>alert(data2[0].text(atfName));</code> and the <code>alert(data2[0].text(atfAmount));</code>  My problem is I can't seem to get the values?  </p>
  
  <p>Let me show you the 2 functions that are ran:  </p>
  
  <p>First this one just sends a url and returns....</p>
  
  <pre><code>function showUrlInDialogATF(urlatf)
      {
        return $.ajax({
          url: urlatf
        });
      }
  </code></pre>
  
  <p>The second one returns the two data values that are created in a <code>document.ready</code> (I have tested them and they do hold values, it's only when I try and get it into the <code>$.when</code> statement).....</p>
  
  <pre><code>function sendUpdateATFwindow()
      {
        return $.ajax({
          data: {
              'atfName': atf_name.val(),
              'atfAmount': atf_amount.val()
          }
        });
      }
  </code></pre>
  
  <p>Let me know if you need anything else, thank you </p>
  
  <p>David</p>
  
  <p>Oh here is the first statement that begins everything:</p>
  
  <pre><code>$(document).ready(function () {     
          $(".atf-submit").click(function () {
                  atf_name = $(this).parent().parent().find(".user_table");
                  atf_amount = $(this).parent().parent().find(".user_atf");
           runATF();
          });
      });
  </code></pre>
  
  <p>Note:  I am using the Jquery UI dialog opener,  I already have one open so I am making another one open.  I don't know if this will effect anything?  I would assume not because the functions and values are different names.</p>
  
  <p>UPDATE:</p>
  
  <p>Okay I want to show the first code that opens the first dialog window up:</p>
  
  <pre><code>$(document).ready(function () {     
          $("#ATF").click(function () {
  
            runATF();
          });
      });
  
      function runATF(){
          var urlATF = '/pcg/ATF/atf_layout.php';
          showUrlInDialogATF(urlATF);
      }
      function showUrlInDialogATF(urlATF)
      {
        var tag = $("#dialog-container");
        $.ajax({
          url: urlATF,
          success: function(data) {
            tag.html(data).dialog
            ({
                width: '100%',
                  modal: true
            }).dialog('open');
          }
        });
      }
  </code></pre>
  
  <p>Than the other code runs - I will re post here:</p>
  
  <pre><code>$(document).ready(function () {     
          $(".atf-submit").click(function () {
                  atf_name = $(this).parent().parent().find(".user_table");
                  atf_amount = $(this).parent().parent().find(".user_atf");
           runATFinsider();
          });
      });
  function runATFinsider(){
          var urlatfinsider = '/pcg/ATF/updateATF_window.php';
          var tagatfinsider = $("#insider_dialog");
  
          var promise1 = showUrlInDialogATFinsider(urlatfinsider);
          var promise2 = sendUpdateATFwindow();
  
          $.when(promise1, promise2).done(function(data1, data2) {
  
              tagatfinsider.html(data1[0]).dialog({
                width: '100%',
                modal: true
              }).dialog('open');
             //$('.updaterATF_outerbody').text(data2[0].atfName),
             //$('.updaterATF_outerbody').text(data2[0].atfAmount)
             console.log(data2[1]);
            alert(data2[0].text(atfName));
          });
      }
      function showUrlInDialogATFinsider(urlatfinsider)
      {
        return $.ajax({
          url: urlatfinsider
        });
      }
      function sendUpdateATFwindow()
      {
        return $.ajax({
          data: {
              'atfName': atf_name.val(),
              'atfAmount': atf_amount.val()
          }
        });
      }
  </code></pre>
  
  <p>Also I try to do a <code>console.log(data2)</code> and it just gives me, [0] = <code>abunch of html?</code> , [1] = <code>success</code>, [2] = <code>object</code></p>
  
  <p>UPDATE:</p>
  
  <p>Here is an example of what it I should be getting in the data2[0]...</p>
  
  <pre><code>alert(atf_name.val()); = bob
  alert(atf_amount.val()); = 0
  </code></pre>