引用JS:
function callWebService(serviceName, params, methodType, offline, callBack, callBackError){ // $.getJSON(common.url + serviceName,params, function(result){ // alert('1111'); // }) // // return; //1. 判断是否有网络 isOnline(function(status){ if(!status){ callBackError(msg.offline); } else{ //2. 判断是否能调通后台服务 if(commonHelper.isNullOrEmpty(methodType)){ methodType = "POST"; } if(commonHelper.isNullOrEmpty(offline)){ offline = false; } //3. 调用 appcan.ajax({ url: common.url + serviceName, data: params, type: methodType, dataType:'json', offline: offline, //timeout: common.timeout, success:function(data, status,requestCode,response, xhr){ callBack(data); }, error:function(xhr, errorType, error, msg){ callBackError(msg); } }); } }); }
调用:
var params = { OrderID : getLocalStorage("OrderID"), strjAppraiseDate: JSON.stringify(jAppraiseDate.appraiseDate), }; callWebService("MyOrder/SummitAppraise", params, "POST", false, function(result){ if(result.isSuccess == "true") { windowAlert("提醒","提交成功","确定") } else{ windowAlert("提醒",result.msg,"确定") } }, function(msg){ windowAlert("提醒",msg,"确定") });
MVC接收
public JsonResult SummitAppraise(string OrderID,string strjAppraiseDate) { string str = strjAppraiseDate; JavaScriptSerializer js = new JavaScriptSerializer(); List<C_Usermenucomment> jg = js.Deserialize<List<C_Usermenucomment>>(str); //JSON直接付给类 MyOrderModel mm = new MyOrderModel(); object obj = mm.SummitAppraise(OrderID,jg); return Json(obj, JsonRequestBehavior.AllowGet); }