AJAX请求服务器端,在ASP.NET MVC下,竟然弹出下载框~
客户端代码如下:
Code
$("#commentForm").submit(function() {
if (!$("#commentForm").valid()) {
return false;
}else{
event.preventDefault();
var groundID =<%=ViewData["GroundID"] %>;
var fengJin = $("#fengJin").val();
var jiaoTong = $("#jiaoTong").val();
var meiShi = $("#meiShi").val();
var zhuSu = $("#zhuSu").val();
var yuLe = $("#yuLe").val();
var content = $("#leavewordContent").val();
var commentContent = $("#commentContent").val();
$("#submitLoading").show();
$.ajax({
type: "POST",
url: "/ground/Json_CommentPost",
data: "groundID="+groundID+"&fengJin="+fengJin+"&jiaoTong="+jiaoTong+"&meiShi"+meiShi+"&zhuSu="+zhuSu+"&yuLe"+yuLe+"&commentContent="+commentContent,
dataType:"json",
success: function(data) {
if(data.isSuccess)
{
$("#submitLoading").hide();
alert("感谢您的评论,我们会尽快审核,谢谢!");
switchingTab($("#liComment"));
}else
{
alert(data.messageContent);
}
}
});
}
服务器端就是一个
return Json(new { isSuccess = isSuccess, messageContent = messageContent });
以json发送AJAX数据,这里的DATA数据不应该是data: "groundID="+groundID+"&fengJin="+fengJin+"&jiaoTong="+jiaoTong这种格式,
而是groundId:'"+groundId+"'这种JSON格式
同问,求解,我用的是Java web,