Background method
Public actionresult Linq () { var lt = Usersys.findall (); New Hashtable (); Ht. ADD ("data", lt); return Json (HT, jsonrequestbehavior.allowget); }
Page elements
<inputtype= "text"name= "ID" /><inputtype= "text"ID= "UserName" /><inputtype= "text"ID= "Active"class= "Active" /><inputtype= "button"class= "Active"value=""/>
JS Request
<script src= "~/scripts/jquery-1.10.2.min.js" ></script><script>$.ajax ({type:' Get ', datatype:' JSON ', URL:'/linq/linq ', Success:function(data) {//get an element based on name to assign a value$ ("[name= ' ID ']"). Val (data.data[1].id); //get elements based on ID to assign values$ ("#UserName"). Val (data.data[1]. UserName); //assign a value based on the class get element$ (". Active"). Val (data.data[1]. PassWord)//filter the type to a button based on the input tag, get the element to assign value$ ("Input[type=button]"). Val ("OK") } })
After removing excess code
// FindAll is a Xcoder generated method without Xcode using LINQ queries can also var lt = Usersys.findall (); // Hashtable ht = new Hashtable (); // ht. ADD ("Data", lt); return Json (LT, jsonrequestbehavior.allowget);
<script src= "~/scripts/jquery-1.10.2.min.js" ></script><script>//simple JQ Gets the element method to return the obtained data directly$.ajax ({type:' Get ', datatype:' JSON ', URL:'/linq/linq ', Success:function(data) {//get an element based on name to assign a value$ ("[name= ' ID ']"). Val (data[1].id); //get elements based on ID to assign values$ ("#UserName"). Val (data[1]. UserName); //assign a value based on the class get element$ (". Active"). Val (data[1]. PassWord)//filter the type to a button based on the input tag, get the element to assign value$ ("Input[type=button]"). Val ("OK") } })
MVC page Simple get get background data