c# - How to assign return value from Json type object into TextBox but i am getting error -


i calling jquery function ajax returned fname,lname,address,email on basic of specified id. returns json type object when going assign these values textbox ,getting error. please me.

<script type="text/javascript">   function bindgridview(id) {   debugger;          var params = "{id:'" + id + "'}";      $.ajax({           type: "post",           url: "insertoningridviewusingjquery.aspx/getrecords",           data: params,           contenttype: "application/json",           datatype: "text",           success: function (data) {           alert(data.d.length);          (var = 0; < data.d.length; i++) {          debugger;                  $("#<%=txtfname.clientid%>").val(data[i].fname);                 $("#<%=txtlname.clientid%>").val(userdetails.lname);                 $("#<%=txtaddress.clientid%>").val(userdetails.address);                 $("#<%=txtemail.clientid%>").val(userdetails.email);                   debugger;              }            }           });       } </script> 

your datatype text , response in json

try this

 datatype: "json", 

and think success function should be

  success: function (data) {       alert(data.d.length);               $("#<%=txtfname.clientid%>").val(data.fname);             $("#<%=txtlname.clientid%>").val(data.lname);             $("#<%=txtaddress.clientid%>").val(data.address);             $("#<%=txtemail.clientid%>").val(data.email);               debugger;          }        } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -