我有一个回复此操作:
return Json(new { success = true, aaa = "bbb" }, "text/html");
如何在我的onComplete函数中访问aaa
?
onComplete: function (file, response)
{
alert(response['aaa']); //undefined
}
答案 0 :(得分:2)
我不熟悉jQuery中的onComplete
。你使用哪种Ajax方法?您可以尝试console.dir(reponse)
代替您的提醒,以准确查看response
参数中的内容。
$.ajax()
method允许您提供complete
处理程序(不带“on”),或实际处理我使用success
处理程序的响应:
$.ajax("yourURLhere", {
success : function(data, textStatus, jqXHR) {
alert(data['aaa']);
},
complete : function(jqXHR, textStatus) {
// do something - note that the parameters don't include "data"
// like the success callback, and "complete" is called after
// the "success" or "error" callback
}
});