<script>window.onload=function () { varstr; //Console.log (@ViewBag. ID);$.post ("/servicebills/servicebills/updatea", {ID: @ViewBag. ID},function(data) { for(varattrinchdata) { //Console.log (attr);//name,age,gender //Console.log (data[attr]);//jack,25,male//Value //Console.log (typeof json1[attr]); //$ ("#" + attr). Val ("111111111"); $("#" + attr). Val (Data[attr]);//ID if((Data[attr] + ""). IndexOf ("/date (")! =-1) {//Timestr = data[attr] + ""; STR= Timestamptotime (str.substring (6, str.length-2));//Conversion Time //Console.log (str); } Else{str=Data[attr]; } if((attr + ""). IndexOf ("Workresult")! =-1) {//contains the Workresult stringConsole.log ("++++"); STR=NULL; } if((attr + ""). IndexOf ("usersatisfaction")! =-1) {Console.log ("----"); STR=NULL; } if(str! =NULL) { $("Input[name=" + attr + "']"). Val (str);//Input Box } //check box if((attr + ""). IndexOf ("Demandtype")! =-1) {//contains the string varSTRs = (Data[attr] + ""). Split (",");//output This string to be split into arrays //Get Collection varOBJS = Document.getelementsbyname ("demandtype[]");//Get collection of objects //Console.log (OBJS); for(vari = 0; i < objs.length; i++) { for(varj = 0; J < Strs.length; J + +) { if(Strs[j].indexof (Objs[i].value) >-1) {//determines whether the value of the object is in this array //Console.log (Strs[j]);objs[i].checked =true;//Select the check box } }; } } if((attr + ""). IndexOf ("Userdemand")! =-1) {//contains the string varSTRs = (Data[attr] + ""). Split (",");//output This string to be split into arrays //Get Collection varOBJS = Document.getelementsbyname ("userdemand[]");//Get collection of objects //Console.log (OBJS); for(vari = 0; i < objs.length; i++) { for(varj = 0; J < Strs.length; J + +) { if(Strs[j].indexof (Objs[i].value) >-1) {//determines whether the value of the object is in this array //Console.log (Strs[j]);objs[i].checked =true;//Select the check box } }; } } //Radio Box //Workresult if((attr + ""). IndexOf ("Workresult")! =-1){ varSTR0 = data[attr] + ""; varOBJS = Document.getelementsbyname ("Workresult");//Get collection of objects //Console.log (OBJS); for(vari = 0; i < objs.length; i++) { //Console.log (objs.length); if(Str0.indexof (Objs[i].value) >-1) {objs[i].checked=true; Console.log (Objs[i].value); } } } if((attr + ""). IndexOf ("usersatisfaction")! =-1) { varSTR0 = data[attr] + ""; varOBJS = Document.getelementsbyname ("usersatisfaction");//Get collection of objects for(vari = 0; i < objs.length; i++) { if(Str0.indexof (Objs[i].value) >-1) {objs[i].checked=true; Console.log (Objs[i].value); } } } } }); } functionTimestamptotime (timestamp) {varDate =NewDate (timestamp * 1);//The timestamp is 10-bit *1000 and the timestamp is 13-bit, so you don't need to multiplyY = date.getfullyear () + '-'; M= (Date.getmonth () + 1 < 10? ' 0 ' + (date.getmonth () + 1): Date.getmonth () + 1) + '-'; D= Date.getdate () + "; H= date.gethours () + ': '; M= date.getminutes () + ': '; S=date.getseconds (); returnY + M + D + H + M +s; } </script>
Post request for JSON data parsing JSON data