title: Uncaught TypeError: Cannot read property 'abort' of undefined
body: <p>I have a problem in my code, a button calls this ajax request from within a jQuery UI dialog </p>
  
  <pre><code>myaudioupload = $.ajax({
          url: "some url",
          type: "POST",
          data: formdata,
          processData: false,
          contentType: false,
          success: function (data) {
          var data = jQuery.parseJSON(data);
          console.log('json parsed');
              if(data.status==1){
                  console.log('status ok');
              }
              else{
                  console.log('status not ok');
              }
          }
      });
  </code></pre>
  
  <p>If the user wants to cancel the request, user closes the dialog box and then the following lines are executed:</p>
  
  <pre><code>close: function(event, ui) { 
      if(myaudioupload.abort()) {
          console.log('aborted');
          $('#uploadaudioform')[0].reset();
      }}
  </code></pre>
  
  <p>This works fine only when the data is being uploaded, not after the upload succeeds or before the upload is triggred. In these conditions, this message shows up </p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot call method 'abort' of undefined </p>
  </blockquote>
  
  <p>I have even tried these ways while aborting: </p>
  
  <pre><code>if(myaudioupload!=='undefined' &amp;&amp; myaudioupload.abort=='function'){
                          myaudioupload.abort();
                          console.log('aborted');
                          $('#uploadaudioform')[0].reset();
                          }
  </code></pre>
  
  <p>but this also does not work; the same error occurs. </p>
  
  <p>So please help me how should i do this or if something is wrong in my code.
  Thanks.</p>