我正在用 Asp.net MVC 开发应用程序。
我使用 jquery 提交表单:
var Data = $("#frmForgotPassword").serialize();
$.post("<%= Url.Action("ForgotPassword","Account") %>/", Data, function(retdata, textStatus) {
if (textStatus == "success") {
if (retdata.status == false) {
$("#error").html('<p class="error">Error: ' + retdata.msg + '</p>');
}
else {
$("#error").html('<div class="clean-ok">Success: ' + retdata.msg + '</div>');
}
}
else
alert("error: " + textStatus);
}, "json");
但是我在文件打开时得到响应,显示在这里。
我的控制器返回 json 如下:
return Json(new { status = false, msg = "User name or email is not registered with us!" });
或者
return Json(new { status = true, msg = "Your username and password has been sent to your email address!" });
那么错误在哪里呢?如何停止以文件形式打开响应?它在 IE 中也给出了同样的错误。
编辑:
请求头:
Host localhost:16293
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
Accept application/json, text/javascript, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Content-Type application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With XMLHttpRequest
Referer http://localhost:16293/Account.aspx/LogOn?ReturnUrl=%2fdefault.aspx
Content-Length 15