谁能告诉我为什么我在这个 jQuery 中的成功回调没有被调用?
$(document).ready(function () {
var queueid = $('#hidqueueid').val();
var queuemax = $('#hidqueuemax').val();
var queuenext = $('#hidqueuenext').val();
var sid = $('#hidsid').val();
var acc = $('#hidacc').val();
var key = getCookie('account_key');
var processNext = function() {
var url = "functions.aspx?sid=" + sid + "&acc=" + acc + "&func=processqueue&id=" + queueid + "&next=" + queuenext + '&key=' + key;
showProgress();
$.post(url, function (data) {
alert(data); // <== never happens :(
var result = $(data).attr('result');
if (result == 'ok') {
queuenext = $(data).attr('next');
if (queuenext > 0) {
$('#hidqueuenext').val(queuenext);
processNext();
} else {
var newurl = 'Data.aspx?sid=' + sid + '&acc=' + acc;
location.href = newurl;
}
}
}, function() {
// error
alert('Oops!');
});
};
var showProgress = function() {
var output = "<div>" + queuenext + " of " + queuemax + "</div>";
$('#divprogress').html(output);
};
processNext();
});
返回结果的 C# 工作正常,如下所示:
string xml = new Queue(sid, acc, queueId).ProcessItem(queueNext, key);
Response.ClearContent();
Response.ContentType = "text/xml";
Response.Write(xml);
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
当我调试 C# 时,XML 看起来不错
谢谢你的帮助!欢迎所有建议。