I have a controller method as below.
public class ProcessorController : System.Web.Http.ApiController
{
[HttpPost]
public void Paid(string confirmationNumber)
{
}
}
I am trying to call this method from a function in angular js as below. The $http.post is not working. I see an error 'The resource cannot be found' in fiddler when it is trying to hit the path that is specified in $http.post. Can anyone please point out what is going wrong here? Thank you!
var payControllers = angular.module('payControllers', []);
payControllers.controller('payCtrl', ['$scope', '$http',
function ($scope, $http) {
$scope.Process = function(confnumber) {
$scope.ConfNumber = confnumber;
if ($scope.ConfNumber.length > 0) {
$http.post('/Processor/Paid',
{
confirmationNumber: $scope.ConfNumber
}
).success(function () {
alert('updated')
});
}
}
}]);
Try it:
var payControllers = angular.module('payControllers', []);
payControllers.controller('payCtrl', ['$scope', '$http',
function ($scope, $http) {
$scope.Process = function(confnumber) {
$scope.ConfNumber = confnumber;
if ($scope.ConfNumber.length > 0) {
$http({
url: '/api/Processor/Paid?confirmationNumber='+$scope.ConfNumber,
method: 'POST'
}).success(function (data) {
alert('updated');
});
}
}
}]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.