I'm trying to call asmx service using AngularJS $http
. But i'm unable to get data from web service. I'm getting a success callback, but the response is the entire html page instead of the object returned as response.
Here is my C# asp.net web service code:
public class DataService : System.Web.Services.WebService
{
[WebMethod]
public Hello HelloWorld()
{
Hello h = new Hello();
h.Message = "Hello World";
return h;
}
}
public class Hello
{
public string Message { get; set; }
}
And here is the AngularJS code
function FormController($scope,$http) {
$scope.submit = function (user) {
var url = '../../Services/DataService.asmx?op=HelloWorld';
$http({
method: "get",
url: url
}).success(function (data, status, headers, config) {
console.log(data);
});
}
FormController.$inject = ['$scope','$http'];
}
the above method is called on form submit.