c# - AngularJS the AJax data not submitting back to HTML -


i have 2 pages index.html , default.aspx. index.html, ajax hit submitted default.aspx process database request , return json string html page. sample code given below.

i'm using angular 1.2.26.

<div ng-app="myapp" ng-controller="customerscontroller">  <ul>   <li ng-repeat="x in names">     {{ x.id + ', ' + x.name}}   </li> </ul> </div> <script type="text/javascript">     var app = angular.module('myapp', []);     function customerscontroller($scope, $http) {                   $scope.response = $http.get("http://localhost/default.aspx")                                .success(function(response) {                  $scope.names = response.records;         });     } </script> 

default.aspx

public static string getemployees() {                  // ... stuff grab data goes here ...       // datarow dr;     foreach (datarow dr in dt.rows)     {         row = new dictionary<string, object>();         foreach (datacolumn col in dt.columns)         {             row.add(col.columnname, dr[col]);         }         rows.add(row);     }      rowcoln.add("records", rows);      string jsondata = serializer.serialize(rowcoln);     //  javascriptserializer serializer = new javascriptserializer();     con.close();    //sample jsondata    jsondata = "{\"records\": [{\"id\":200321,\"name\": \"test\"}]}";     return jsondata;  } 

the jsondata receiving data not returning html page.

you have use $scope.$apply
refer: http://jimhoskins.com/2012/12/17/angularjs-and-apply.html
refer: https://github.com/angular/angular.js/wiki/when-to-use-$scope.$apply()


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -