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
Post a Comment