ajax什么情况回调error,大家帮帮我,Ajax请求的json格式怎么有时会回调到success可是有时会回调到error函数里去呢?...

//获取待审核笑话

function GetArticle() {

$(".btn_review").attr("disabled", "disabled");

$.ajax({

url: "/ajax/xx.ashx",

type: "post",

dataType: "json",

async: false,

data: { action: "Manuscript" },

beforeSend: function (data) {

            $("#revcontent").html("

load.gif%5C%22正在努力加载笑话……

");

},

success: function (data) {

if (data.status == "success") {

//已登录则加载待审核内容

jokeid = data.jokeid;

if (data.title != "") {

$("#revtitle").text(data.title);

$("#revtitle").show();

} else {

$("#revtitle").text("");

$("#revtitle").hide();

}

$("#revcontent").html(data.content);

if (data.img != "") {

                    $("

%5C%22%22

").appendTo("#revcontent");

}

$(".btn_review").removeAttr("disabled");

} else if (data.status == "nologin") {

showmodel();

$("#revcontent").html("

你还没有登陆或者登陆超时,请重新登陆!

");

$("#revtitle").text("");

$("#revtitle").hide();

} else {

$("#revcontent").html("

" + data.msg + "

");

$("#revtitle").text("");

$("#revtitle").hide();

}

},

error: function (data) {

alert(data.status+";" + data.responseText);

}

});

}

//审核笑话

function revjoke(revstatus) {

if (jokeid == 0) {

GetArticle();

return false;

}

var jid = jokeid;

jokeid = 0;

$(".btn_review").attr("disabled", "disabled");

if (revstatus == 2) {

GetArticle();

} else {

$.ajax({

url: "/ajax/xx.ashx",

dataType: "json",

async: false,

type: "post",

data: { aid: jid, result: revstatus, action: "rew" },

success: function (data) {

if (data.status == "success") {

if (revstatus == 0) {

$("#alertrevfile").show();

} else if (revstatus == 1) {

$("#alertrevsuccess").show();

}

setTimeout(function () {

$(".alertrevstatus").hide();

GetArticle();

}, 1000);

} else if (data.status == "nologin") {

showmodel();

} else {

$("#revcontent").html("

" + data.msg + "

");

}

}

});

}

}

以上是jQuery的Ajax请求,

be7ff103ea9f45b89ad3d13ceaa76c19.png

我点击换一个的时候就执行GetArticle()方法,可是怎么会有时请求回调成功,有时会到error里面去呢?求大神给指点,急啊

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值