在jquery中。
我想要一些可以作为成功参数的东西,但是在调用函数时运行,而不是一旦我得到响应。
示例(oajax是开放身份验证的ajax的扩展名)
$.oajax({
url: url,
jso_provider: "facebook", // Will match the config identifier
jso_scopes: false, // List of scopes (OPTIONAL)
dataType: 'json',
success: function(data) {
fbposts=data.data
//a bunch of code irellevant for the question
},//success done
error: function() {
console.log("ERROR Custom callback()");
}
})
};
答案 0 :(得分:5)
答案 1 :(得分:0)
在普通的ajax函数中,将其作为beforeSend传递:
$.ajax({
url: url,
dataType: 'json',
beforeSend: function(jqXHR, status){
// CODE HERE
},
success: function(data) {
fbposts=data.data
},
error: function() {
console.log("ERROR Custom callback()");
}
})
};
你必须检查oajax是否也有这个事件,但它可能会