Reference JS:
functionCallwebservice (ServiceName, params, methodtype, offline, CallBack, callbackerror) {//$.getjson (common.url + servicename,params, function (result) { //alert (' 1111 '); // })// //return; //1. Determine if there is a networkIsOnline (function(status) {if(!status) {Callbackerror (msg.offline); } Else{ //2. Determine if the background service can be transferred if(Commonhelper.isnullorempty (Methodtype)) {Methodtype= "POST"; } if(Commonhelper.isnullorempty (offline)) {offline=false; } //3. CallAppcan.ajax ({url:common.url+ServiceName, Data:params, Type:methodtype, DataType:' JSON ', Offline:offline,//Timeout:common.timeout,Successfunction(data, Status,requestcode,response, XHR) {callBack (data); }, Error:function(XHR, ErrorType, error, msg) {callbackerror (msg); } }); } }); }
Call:
varparams ={orderid:getlocalstorage ("OrderID"), StrjAppraiseDate:JSON.stringify (jappraisedate.appraisedate),}; Callwebservice ("Myorder/summitappraise", params, "POST",false,function(Result) {if(result.issuccess = = "true") {Windowalert ("Reminder", "Commit succeeded", "OK") } Else{Windowalert ("Reminders", result.msg, "OK") } }, function(msg) {Windowalert ("Reminder", MSG, "OK") });
MVC receive
PublicJsonresult Summitappraise (stringOrderID,stringstrjappraisedate) { stringstr =strjappraisedate; JavaScriptSerializer JS=NewJavaScriptSerializer (); List<C_Usermenucomment> JG = js. Deserialize<list<c_usermenucomment>>(str); JSON is paid directly to class Myordermodel mm=NewMyordermodel (); Objectobj =mm. Summitappraise (ORDERID,JG); returnJson (obj, jsonrequestbehavior.allowget); }
Appcan Communication (Appcan.ajax)