Workaround
Go to www.json.org download json2.js
Then call Json.stringify (Jsondata) to convert the JSON object into a JSON string.
var people = [{"UserName": "T1", "PassWord": "111111", "Sex": "Male"}, {"UserName": "T2", "PassWord": "222222", "Sex": "Female" }];
Re-construct the URL back to the server side:
$ ("#btnSend"). Bind ("click", Function () {
$.post ("A.ashx", {xxxx:JSON.stringify (People)}, function (data, returnstatus) {}, "JSON");
});
functionCustomercheck () {selectrows= $ ("#ui_customerCheck_dg"). DataGrid (' Getselections '); varJsondata =json.stringify (selectrows); Console.info (Jsondata); if(Selectrows.length > 0) {console.info (selectrows); $.ajax ({URL:' Ashx/bg_customercheck.ashx?action=checkedpass ', data: {"Selectrows": Jsondata}, DataType:' HTML ', Success:function(rData) {varDatajson = eval (' (' + rData + ') ');//turn into JSON format if(datajson.success) {$.show_warning (Prompted, datajson.msg); $("#ui_customerCheck_dg"). DataGrid ("Reload"). DataGrid (' Clearselections '). DataGrid (' clearchecked '); } Else{$.show_warning (Prompted, datajson.msg); } } }); } Else{$.show_warning ("Prompt", "Please select the document that needs to be audited!" "); return; } //Console.info (selectrows); //$ ("#ui_customerCheck_dg"). DataGrid (' Unselectall '); }
usingSystem;usingSystem.Collections.Generic;usingsystem.web;usingLT. Epc. BLL;usingLT.EPC.Common;usingLT. Epc. Model;usingLT. Epc. Sqlserverdal;namespaceLT. Epc. webui.admin.ashx{/// <summary> ///Summary description of Bg_customercheck/// </summary> Public classBg_customercheck:ihttphandler { Public voidProcessRequest (HttpContext context) {context. Response.ContentType="Application/json"; stringAction = context. request.params["Action"]; Useroperatelogdatacontract Useroperatelog=NULL;//Action Log Object Try{userdatacontract User= Userhelper.getuser (context);//get the user object in the cookieUseroperatelog =Newuseroperatelogdatacontract (); Useroperatelog.userip=Commonhelper.getip (context. request.userhostaddress); Useroperatelog.username=user. UserId; Switch(action) { Case "Checkedpass": varSelectrowsjson = context. request.params["selectrows"] ??""; List<UserDataContract> userlist =deserializeuserlist (Selectrowsjson); List<CustomerCheckDataContract> checklist =deserializechecklist (Selectrowsjson); if(Newcustomercheckmgr (). Changeorderstatus (Checklist)) {Useroperatelog.operateinfo="Customer Service Audit"; Useroperatelog.ifsuccess=true; Useroperatelog.description="Audit through"+NULL; Context. Response.Write ("{\ "msg\": \ "Audit passed! \ ", \" Success\ ": true}"); } Else{useroperatelog.operateinfo="Customer Service Audit"; Useroperatelog.ifsuccess=false; Useroperatelog.description="Customer serviceAudit Failure"; Context. Response.Write ("{\ "msg\": \ "Customer Service Audit failed! \ ", \" Success\ ": false}"); } useroperatelogmgr.insertoperateinfo (Useroperatelog); Break; default: Context. Response.Write ("{\ "result\": \ "parameter Error! \ ", \" Success\ ": false}"); Break; } } Catch(Exception ex) {context. Response.Write ("{\ "msg\": \ ""+ Jsonhelper.stringfilter (ex. Message) +"\ ", \" Success\ ": false}"); Useroperatelog.operateinfo="Customer Service Audit function Exception"; Useroperatelog.ifsuccess=false; Useroperatelog.description=Jsonhelper.stringfilter (ex. Message); Useroperatelogmgr.insertoperateinfo (Useroperatelog); } } Public BOOLisreusable {Get { return false; } } //convert JSON directly into an entity object PublicList<userdatacontract> Deserializeuserlist (stringJSON) { varU = jsonhelper.fromjson<list<userdatacontract>>(JSON); returnu; } //convert JSON directly into an entity object PublicList<customercheckdatacontract> Deserializechecklist (stringJSON) { varo = jsonhelper.fromjson<list<customercheckdatacontract>>(JSON); returno; } }}
Using AJAX to pass JSON arrays in MVC