Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 中止AJAX请求ZeptoJS_Javascript_Ajax_Zepto - Fatal编程技术网

Javascript 中止AJAX请求ZeptoJS

Javascript 中止AJAX请求ZeptoJS,javascript,ajax,zepto,Javascript,Ajax,Zepto,我想知道是否有办法中止ZeptoJS中的AJAX调用,就像我在jQuery中使用的.abort()一样 我已经尝试过了,但我一直遇到以下错误: Uncaught TypeError: Object #<t> has no method 'abort' 我正在对变量调用.abort(): if ( SITE.Address.pendingZipLookup !== null && SITE.Address.pendingZipLookup.readyState !=

我想知道是否有办法中止ZeptoJS中的AJAX调用,就像我在jQuery中使用的
.abort()
一样

我已经尝试过了,但我一直遇到以下错误:

Uncaught TypeError: Object #<t> has no method 'abort' 
我正在对变量调用
.abort()

if ( SITE.Address.pendingZipLookup !== null && SITE.Address.pendingZipLookup.readyState !== 4 ) {
    console.log(SITE.Address.pendingZipLookup.readyState);
    SITE.Address.pendingZipLookup.abort();
}
.readyState
都不会计算,它只会在控制台中返回
未定义的

编辑:这是登录控制台时
SITE.Address.pendingZipLookup
的外观:

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<=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"&&n.call(this,this)}
    done: function (){var t,i,u,f=this;return(t=1<=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"&&(this._doneCallbacks||(this._doneCallbacks=[]),(u=this._doneCallbacks).push.apply(u,i)),this)}
    fail: function (){var t,i,u,f=this;return(t=1<=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"&&(this._failCallbacks||(this._failCallbacks=[]),(u=this._failCallbacks).push.apply(u,i)),this)}
    notify: function (){var t;return t=1<=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<=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:((r=this._progressCallbacks)!=null&&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<=arguments.length?n.call(arguments,0):[],t!=null?(i=t.apply(this,u),f(i)?i.done(function(){var t,i;return t=1<=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<=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<=arguments.length?n.call(arguments,0):[],i!=null?(u=i.apply(this,t),f(u)?u.done(function(){var t,i;return t=1<=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<=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<=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<=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<=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:(this._state="rejected",this._withArguments=t,this._context=i,(r=this._failCallbacks)!=null&&r.forEach(function(n){return n.apply(f._context,t)}),(u=this._alwaysCallbacks)!=null&&u.forEach(function(n){return n.apply(f._context,t)}),this)}
    resolve: function (){var t;return t=1<=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<=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:(this._state="resolved",this._context=i,this._withArguments=t,(r=this._doneCallbacks)!=null&&r.forEach(function(n){return n.apply(f._context,t)}),(u=this._alwaysCallbacks)!=null&&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
t{u:e}
_延期:e
_上下文:窗口
_承诺:t
_国家:“已解决”
_withArguments:数组[3]
始终:函数(){返回n.apply(t,参数)}
完成:函数(){返回n.apply(t,参数)}
失败:函数(){返回n.apply(t,参数)}
notify:function(){返回n.apply(t,参数)}
notifyWith:function(){返回n.apply(t,参数)}
管道:函数(){返回n.apply(t,参数)}
进程:函数(){返回n.apply(t,参数)}
承诺:函数(){返回n.apply(t,参数)}
拒绝:函数(){返回n.apply(t,参数)}
rejectWith:函数(){返回n.apply(t,参数)}
解析:函数(){返回n.apply(t,参数)}
resolveWith:function(){返回n.apply(t,参数)}
然后:函数(){返回n.apply(t,参数)}
__原型:e
总是:函数(){var t,i,u,f=this;返回(t=1
  • 首先,您需要获取“request”实例。如果您使用
    $.ajax
    ,那么
    var request=$.ajax(选项)
  • 然后您可以像这样编写:
    request.abort();
如果无法获取请求实例,我认为没有任何方法可以中止请求


您可以粘贴代码。

似乎SITE.Address.pendingZipLookup==未定义。请尝试以下代码:if(SITE.Address.pendingZipLookup!=未定义和SITE.Address.pendingZipLookup!=null和SITE.Address.pendingZipLookup.readyState!=4){//todo:}我在问题描述中添加了
SITE.Address.pendingZipLookup
的输出,它似乎没有任何
abort()
方法…就在SITE.Address.pendingZipLookup=$.ajax({})行之后;尝试在firebug中查看变量,我确信您可以看到一个名为abort()的方法。你说的“监视”是什么意思?我使用Chrome的调试工具,我可以使用这些工具吗?Chrome也可以。在该行中添加一个断点(在“源”选项卡中),当代码运行到此断点时,监视变量(只需将鼠标移到变量上)。
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<=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"&&n.call(this,this)}
    done: function (){var t,i,u,f=this;return(t=1<=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"&&(this._doneCallbacks||(this._doneCallbacks=[]),(u=this._doneCallbacks).push.apply(u,i)),this)}
    fail: function (){var t,i,u,f=this;return(t=1<=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"&&(this._failCallbacks||(this._failCallbacks=[]),(u=this._failCallbacks).push.apply(u,i)),this)}
    notify: function (){var t;return t=1<=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<=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:((r=this._progressCallbacks)!=null&&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<=arguments.length?n.call(arguments,0):[],t!=null?(i=t.apply(this,u),f(i)?i.done(function(){var t,i;return t=1<=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<=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<=arguments.length?n.call(arguments,0):[],i!=null?(u=i.apply(this,t),f(u)?u.done(function(){var t,i;return t=1<=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<=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<=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<=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<=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:(this._state="rejected",this._withArguments=t,this._context=i,(r=this._failCallbacks)!=null&&r.forEach(function(n){return n.apply(f._context,t)}),(u=this._alwaysCallbacks)!=null&&u.forEach(function(n){return n.apply(f._context,t)}),this)}
    resolve: function (){var t;return t=1<=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<=arguments.length?n.call(arguments,1):[],this._state!=="pending")?this:(this._state="resolved",this._context=i,this._withArguments=t,(r=this._doneCallbacks)!=null&&r.forEach(function(n){return n.apply(f._context,t)}),(u=this._alwaysCallbacks)!=null&&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