我有这样的代码
var ajaxrequest = $.ajax({
type: "POST",
dataType: "json",
url: "xy.php",
data: {
action : "read"
}
}).fail(function(){
//something to do when ajaxreq fails
}).done(function(data){
//something to do when ajaxreq is done
});
它没有问题.我的问题是为什么这不起作用:
var ajaxrequest = $.ajax({
type: "POST",
dataType: "json",
url: "n3_vaje_api.php", //Relative or absolute path to response.php file
data: {
action : "read",
},
fail:function(){
//something to do when ajaxreq fails
},
done:function(data){
//something to do when ajaxreq is done
}
});
失败和完成只是示例,如果在内部使用完成也不起作用.但在外面使用它像:
ajaxrequest.complete(f(){});
工作得很好……我知道我应该使用成功而不是完成,但这不是我的观点.
什么交易在这里?