javascript - how to retrieve properly Json content form asp.net web-service function using angularJs vs Ajax -


i pretty new angularjs, , taring json content angularjs asp.net web service using webmethod function , getting error 500

asp.net:

[webmethod] public string jasontemp() {     blfrontend.frontend blfrontendhendler = new frontend();     bindinglist<product> productlisthendler = blfrontendhendler.listofproducts();     string json = jsonconvert.serializeobject(productlisthendler, formatting.indented);     return json; } 

javascript:angular - controller:

webstorecontrollers.controller('listcontroller', ['$scope', '$http', function ($scope, $http) {     $http.get('/webstorewstohtml.asmx/jasontemp').success(function (data) {         $scope.products = data;     }); }]); 

but when using ajax it's working properly

javascript:ajax:

function callsvc1() {     $.ajax({         type: "post",         url: "webstorewstohtml.asmx/jasontemp",         data: "",         contenttype: "application/json; charset=utf-8",         datatype: "json",         success: function (data, status) { alert(data.d); },         error: function (request, status, error) { alert(request.responsetext); }     }); } 


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -