asp.net - how do I parse the http response object coming from asmx -
$scope.edit = function (id) { console.log("edit id : " + id); $scope.employee = {}; $scope.eid = id; var data = json.stringify({empid: $scope.eid}); var url = "/services/employeeservice.asmx/editemployee"; $http.post(url, data).then(function (response) { $scope.employee = response.data; console.log($scope.employee.fname); console.log($scope.employee); var mydata = jquery.parsejson(json.stringify(response.data)); console.log(mydata); }, function (response) { console.log(response.status); console.log(response.statustext); }); }
[webmethod] [scriptmethod(responseformat = responseformat.json)] public string editemployee(int empid) { employee employee = new employee(); if (emplist.count > 0) { foreach (employee emp in emplist) { if (emp.empid == empid) { employee.empid = empid; employee.fname = emp.fname; employee.city = emp.city; employee.mobile = emp.mobile; employee.country = emp.country; break; } } } javascriptserializer js = new javascriptserializer(); context.response.clear(); context.response.contenttype = "application/json"; list<employee> elist = new list<employee>(); elist.add(employee); return new javascriptserializer().serialize(elist); }
this got response
object d:"[{"empid":103,"fname":"sujith","city":"trichy","mobile":"56456456","country":"india"}]" proto : object
how parse angular js object. want access this: $scop.employee.empid,$scope.employee.fname
thanks & regards arun
are sure object receiving starting , ending " " (double quotes)
Comments
Post a Comment