title: How to get variable created in ajax.done outside of the function
body: <p>The issue that the below code snippet has is the value of <code>data.status</code> is not conserved out of the <code>ajax.done</code> function. I've already tried as shown in the below snippet to make a hidden input and add the value attribute with the value of <code>data.status</code>. This has also failed. My only conclusion is that the value is only conserved while inside of the <code>ajax.done</code> function even if the value attribute was assigned to the hidden input then outside of the <code>ajax.done</code> function it will return as &quot;undefined&quot;. How could I get the value of <code>data.status</code> outside of the <code>ajax.done</code> function.</p>
  <pre class="lang-js prettyprint-override"><code>$.ajax({
      method: 'POST',
      url: &quot;{{ url_for('admin.adminAccountsValidateUserManagementProcessName') }}&quot;
  }).done(function(data) {
      console.log(data.status);
      $(&quot;#hidden-inpt&quot;).attr(&quot;value&quot;, data.status);
      console.log(&quot;hidden input value: &quot;, $(&quot;#hidden-inpt&quot;).attr(&quot;value&quot;));
  });
  let status = $(&quot;#hidden-inpt&quot;).attr(&quot;value&quot;);
  console.log(status);
  return false;
  </code></pre>