triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false) return false
triggerGlobal(settings, context, 'ajaxSend', [xhr, settings])
}
function ajaxSuccess(data, xhr, settings) {
var context = settings.context,
status = 'success'
settings.success.call(context, data, status, xhr)
triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data])
ajaxComplete(status, xhr, settings)
}
// type: "timeout", "error", "abort", "parsererror"
function ajaxError(error, type, xhr, settings) {
var context = settings.context
settings.error.call(context, xhr, type, error)
triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error])
ajaxComplete(type, xhr, settings)
}
// status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
function ajaxComplete(status, xhr, settings) {
var context = settings.context
settings.complete.call(context, xhr, status)
triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings])
ajaxStop(settings)
}
// Empty function, used as default callback
function empty() {}
//可参考http://zh.wikipedia.org/zh-cn/JSONP
$.ajaxJSONP = function(options) {
if (!('type' in options)) return $.ajax(options)
var callbackName = 'jsonp' + (++jsonpID), //创建回调函数名
script = document.createElement('script'),
//js文件加载完毕
cleanup = function() {
clearTimeout(abortTimeout) //清除下面的timeout事件处理
$(script).remove() //移除创建的script标签,因为该文件的JS内容已经解析过了
delete window[callbackName] //清除掉指定的回调函数
},
//取消加载
abort = function(type) {
cleanup()
// In case of manual abort or timeout, keep an empty function as callback
// so that the SCRIPT tag that eventually loads won't result in an error.
//这里通过将回调函数重新赋值为空函数来达到看似阻止加载JS的目的,实际上给script标签设置了src属性后,请求就已经产生了,并且不能中断
if (!type
关键词:zepto是啥