这是一个 MVC3 应用程序。我对我的操作有以下 javascript 调用:
function editDescription(docId,fileName, fileDescription) {
$.ajax({
type: "POST",
url: "/OrderDetail/LoadModelData",
contentType: "application/json; charset=utf-8",
data: "{'id': '"+docId +"', 'filename': '"+fileName+"', 'description': '"+fileDescription+"'}",
dataType: "json",
success: function (result) {
alert("ok: "+ result.d);
},
error: function (result) {
alert('Oh no: '+ result.responseText);
}
});
这是我的行动:
[HttpPost]
public string LoadModelData(string id, string filename, string description)
{
return filename;
}
我运行代码,使用参数调用动作,没有什么是空的,但每次都会调用错误函数。所以每次都会出现带有“Oh no”的警告框,但是从操作返回的字符串是正确的。如果文件名是 test.pdf,则错误警报框会显示
'Oh No: test.pdf'.
我查看了 Firebug,没有错误。尽管没有错误,为什么不调用成功函数?