Ajax使用案例
前台方法:
var senddata = { SiteGroupID: nodeId };
$.ajax({
type: "Post",//这里是http类型
//contentType:"application/json",//这里设置发往服务端的数据类型
url: "CheckSiteGroup",
data: senddata,//回传一个参数
dataType: "json",//传回来的数据类型
success: function (dataResult) {
debugger;
if (dataResult) {
splitter.ajaxRequest("#rightpane", "/ComplaintRegistration/GoodEnginRegistionAdd?rd=" + Math.random(), { SiteGroupID: nodeId });
}
else {
alert("只有已竣工工程才允许登记");
}
},
error: function () {
debugger;
}
});
后台方法:
public ActionResult CheckSiteGroup(Guid SiteGroupID)
{
var result = false;
var siteGroup = _serviceSiteGroup.GetSiteGroupById(SiteGroupID);
if(siteGroup.EngineeringState == SiteGroupState.已完工)
{
result = true;
}
return AjaxResult(result, result);
}