1

I have to fetch a string from aspx to angularJS and display it. But I am not getting any response or it might be AngularJS is not triggering the method. Here is my Angular Controller

controller('ReadTextController', function ($scope, $http, $location) {

        $scope.showData = function () {
            $http.post('KeyPhraseGroup.aspx/GetEmployees', { data: {} })  
.success(function (data, status, headers, config) {  
    $scope.result = data.d;  
})  
.error(function (data, status, headers, config) {  
    $scope.status = status;  
});  
}  
});

And here is my aspxmethod

[WebMethod]
    public static string GetEmployees()
    {
        return "Hello World";
    }

I am triggering the showData() method of the AngularJS controller in my html page but not getting the string fetched.

Changed Explanation

I am getting value as undefined

4
  • Possible duplicate of Get Json Data From Asp.Net Webmethod and Consume in angularJS Commented Oct 5, 2016 at 13:15
  • I am doing the same but getting value as undefined Commented Oct 5, 2016 at 13:30
  • Do you mean aspx page when you refer to html page? Commented Oct 5, 2016 at 15:40
  • Ya I mean aspx page Commented Oct 6, 2016 at 6:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.