Note that there are some explanatory texts on larger screens.

plurals
  1. POAbort AJAX Request ZeptoJS
    text
    copied!<p>I was wondering if there is way to abort an AJAX call in ZeptoJS the same I would use <code>.abort()</code> in jQuery.</p> <p>I've tried it but I keep getting this error : </p> <pre><code>Uncaught TypeError: Object #&lt;t&gt; has no method 'abort' </code></pre> <p>This is what the AJAX call looks like :</p> <pre><code>SITE.Address.pendingZipLookup = $.ajax({ url: '/us/en-us/services/globalization/getcitysuggestions', data: {"ZipCode" : newZipCode}, type: 'POST', success: function (data) { if(SITE.Address.suppressZipLookup) return; if(data.length === 0) { SITE.Navigation.showModal( SITE.TextTranslations.address.noAddressText , SITE.TextTranslations.address.noAddressHeading ); } else if(data.length == 1) { SITE.Address.fillAddressElm($addressFormItem, data[0]); } else { SITE.Navigation.showModal( Mustache.to_html( $tmplSelectCity.html(), {Cities: data} ) , SITE.TextTranslations.address.selectCity ); $('.modal').find('.modal-header .buttonClose').one('click', clearForm).end(); } }, error: function() {} }); </code></pre> <p>And I'm calling the <code>.abort()</code> on the variable :</p> <pre><code>if ( SITE.Address.pendingZipLookup !== null &amp;&amp; SITE.Address.pendingZipLookup.readyState !== 4 ) { console.log(SITE.Address.pendingZipLookup.readyState); SITE.Address.pendingZipLookup.abort(); } </code></pre> <p>Neither the <code>.readyState</code> evaluates, it just returns <code>undefined</code> in the console.</p> <p><strong>EDIT :</strong> This is how the <code>SITE.Address.pendingZipLookup</code> looks when logged in the console :</p> <pre><code>t {_deferred: e} _deferred: e _context: Window _promise: t _state: "resolved" _withArguments: Array[3] always: function (){return n.apply(t,arguments)} done: function (){return n.apply(t,arguments)} fail: function (){return n.apply(t,arguments)} notify: function (){return n.apply(t,arguments)} notifyWith: function (){return n.apply(t,arguments)} pipe: function (){return n.apply(t,arguments)} progress: function (){return n.apply(t,arguments)} promise: function (){return n.apply(t,arguments)} reject: function (){return n.apply(t,arguments)} rejectWith: function (){return n.apply(t,arguments)} resolve: function (){return n.apply(t,arguments)} resolveWith: function (){return n.apply(t,arguments)} then: function (){return n.apply(t,arguments)} __proto__: e always: function (){var t,i,u,f=this;return(t=1&lt;=arguments.length?n.call(arguments,0):[],t.length===0)?this:(i=r(t),this._state==="pending"?(this._alwaysCallbacks||(this._alwaysCallbacks=[]),(u=this._alwaysCallbacks).push.apply(u,i)):i.forEach(function(n){return n.apply(f._context,f._withArguments)}),this)} constructor: function e(n){this.then=t(this.then,this),this.resolveWith=t(this.resolveWith,this),this.resolve=t(this.resolve,this),this.rejectWith=t(this.rejectWith,this),this.reject=t(this.reject,this),this.promise=t(this.promise,this),this.progress=t(this.progress,this),this.pipe=t(this.pipe,this),this.notifyWith=t(this.notifyWith,this),this.notify=t(this.notify,this),this.fail=t(this.fail,this),this.done=t(this.done,this),this.always=t(this.always,this),this._state="pending",typeof n=="function"&amp;&amp;n.call(this,this)} done: function (){var t,i,u,f=this;return(t=1&lt;=arguments.length?n.call(arguments,0):[],t.length===0)?this:(i=r(t),this._state==="resolved"?i.forEach(function(n){return n.apply(f._context,f._withArguments)}):this._state==="pending"&amp;&amp;(this._doneCallbacks||(this._doneCallbacks=[]),(u=this._doneCallbacks).push.apply(u,i)),this)} fail: function (){var t,i,u,f=this;return(t=1&lt;=arguments.length?n.call(arguments,0):[],t.length===0)?this:(i=r(t),this._state==="rejected"?i.forEach(function(n){return n.apply(f._context,f._withArguments)}):this._state==="pending"&amp;&amp;(this._failCallbacks||(this._failCallbacks=[]),(u=this._failCallbacks).push.apply(u,i)),this)} notify: function (){var t;return t=1&lt;=arguments.length?n.call(arguments,0):[],this.notifyWith.apply(this,[i].concat(n.call(t))),this} notifyWith: function (){var t,i,r;return(i=arguments[0],t=2&lt;=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:((r=this._progressCallbacks)!=null&amp;&amp;r.forEach(function(n){return n.apply(i,t)}),this)} pipe: function (t,i){var r;return r=new e,this.done(function(){var u,i,e;return u=1&lt;=arguments.length?n.call(arguments,0):[],t!=null?(i=t.apply(this,u),f(i)?i.done(function(){var t,i;return t=1&lt;=arguments.length?n.call(arguments,0):[],(i=r.resolveWith).call.apply(i,[r,this].concat(n.call(t)))}).fail(function(){var t,i;return t=1&lt;=arguments.length?n.call(arguments,0):[],(i=r.rejectWith).call.apply(i,[r,this].concat(n.call(t)))}):r.resolveWith.call(r,this,i)):(e=r.resolveWith).call.apply(e,[r,this].concat(n.call(u)))}),this.fail(function(){var t,u,e,o;return t=1&lt;=arguments.length?n.call(arguments,0):[],i!=null?(u=i.apply(this,t),f(u)?u.done(function(){var t,i;return t=1&lt;=arguments.length?n.call(arguments,0):[],(i=r.resolveWith).call.apply(i,[r,this].concat(n.call(t)))}).fail(function(){var t,i;return t=1&lt;=arguments.length?n.call(arguments,0):[],(i=r.rejectWith).call.apply(i,[r,this].concat(n.call(t)))}):r.rejectWith.call(r,this,u),(e=r.rejectWith).call.apply(e,[r,this].concat(n.call(t)))):(o=r.rejectWith).call.apply(o,[r,this].concat(n.call(t)))}),r.promise()} progress: function (){var t,i,u;return(t=1&lt;=arguments.length?n.call(arguments,0):[],t.length===0||this._state!=="pending")?this:(i=r(t),this._progressCallbacks||(this._progressCallbacks=[]),(u=this._progressCallbacks).push.apply(u,i),this)} promise: function (){return this._promise||(this._promise=new u(this))} reject: function (){var t;return t=1&lt;=arguments.length?n.call(arguments,0):[],this.rejectWith.apply(this,[i].concat(n.call(t))),this} rejectWith: function (){var t,i,r,u,f=this;return(i=arguments[0],t=2&lt;=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:(this._state="rejected",this._withArguments=t,this._context=i,(r=this._failCallbacks)!=null&amp;&amp;r.forEach(function(n){return n.apply(f._context,t)}),(u=this._alwaysCallbacks)!=null&amp;&amp;u.forEach(function(n){return n.apply(f._context,t)}),this)} resolve: function (){var t;return t=1&lt;=arguments.length?n.call(arguments,0):[],this.resolveWith.apply(this,[i].concat(n.call(t))),this} resolveWith: function (){var t,i,r,u,f=this;return(i=arguments[0],t=2&lt;=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:(this._state="resolved",this._context=i,this._withArguments=t,(r=this._doneCallbacks)!=null&amp;&amp;r.forEach(function(n){return n.apply(f._context,t)}),(u=this._alwaysCallbacks)!=null&amp;&amp;u.forEach(function(n){return n.apply(f._context,t)}),this)} state: function (){return this._state} then: function (n,t,i){return this.done(n),this.fail(t),this.progress(i),this} __proto__: Object </code></pre> <p>If it looks strange it's because I copied the object I got in the console, if there is a better way of printing out the result someone should let me know :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload