我在这里同意Maz的观点,您仍然可以从查询处理和对象创建中受益,并且也无需为此修补jquery
但是,如果您不介意修补jquery,则可以添加以下行
// The readystate 2 } else if ( !requestDone && xhr && xhr.readyState === 2 && isTimeout !== 'timeout' && s.state2) { s.state2.call( s.context, data, status, xhr ); // The readystate 3 } else if ( !requestDone && xhr && xhr.readyState === 3 && isTimeout !== 'timeout' && s.state3) { s.state3.call( s.context, data, status, xhr );在此行之前:(jQuery v 1.4.4)或仅在源代码中搜索readyState === 4
// The transfer is complete and the data is available, or the request timed out } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {现在您可以再次使用$ .ajax并为state2和state3设置一个处理程序,如下所示:
$.ajax({ url: 'http://www.stackoverflow.com', cache: false, success:function(){console.log('success');}, error: function (){console.log('error');}, complete: function (){console.log('complete');}, state2: function (context,data,status,xhr) {console.log('state2');}, state3: function (context,data,status,xhr) {console.log('state3');}});它的行为与其他处理程序完全不同,例如returngin false不会做任何事情,但是您仍然可以处理xhr对象并以这种方式中止
虐待看看我是否可以在今天晚些时候将其提交以包含在源中,谁知道他们可能会接受它



