title: jquery mobile : Uncaught TypeError: Cannot read property 'abort' of undefined error in ajax call
body: <p>hello i have made a site with jquery mobile and i am using auto complete of jquery mobile i want abort previous request of ajax but i face the error of <code>Cannot read property 'abort' of undefined</code>
  here is my code :</p>
  
  <pre><code>&lt;div id="myPage"&gt;  
    &lt;ul id="autocomplete" data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Find a city..." data-filter-theme="a"&gt;&lt;/ul&gt;                  
  &lt;/div&gt;
  </code></pre>
  
  <p>and here is js code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     var xhr ;
     $(document).on( "pageinit", function() {
         autoComplete();
     });
     function autoComplete(){ 
  $( ".ui-input-text" ).on( "keyup", function ( e, data ) {   
         var $ul = $('#autocomplete'),
             $input = $(this),
             value = $input.val(),
             html = "";
      $ul.html( "" );
      if ( value &amp;&amp; value.length &gt; 1 ) {
          $ul.html( "&lt;li&gt;&lt;div class='ui-loader'&gt;&lt;span class='ui-icon ui-icon-loading'&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;" );
          $ul.listview( "refresh" );
          console.log(xhr);
          if(xhr &amp;&amp; xhr.readystate != 4 &amp;&amp;  typeof xhr !== 'undefined'){
              xhr.abort();
          }
  
          xhr = $.ajax({
              url: "http://gd.geobytes.com/AutoCompleteCity",
              type:'POST',
              dataType: "jsonp",
              data: {
                   q: $input.val(),
              }
         })
         .then( function ( response ) {
              $ul.html( response );
              $ul.listview( "refresh" );
              $ul.trigger( "updatelayout");               
         });      
       }
    });   
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is <code>DEMO</code> link : <a href="http://dev.artoonsolutions.com/jignesh/mobile_auto/index.html" rel="nofollow">http://dev.artoonsolutions.com/jignesh/mobile_auto/index.html</a></p>