user3315871
user3315871

Reputation:

Argument 'fn' is not a function, got Object angularjs [ng:areq]

net service from my angular application. i'm using http post method. so when i'm calling the service it respond back but additionally i get "Argument 'fn' is not a function, got Object" error in chrome console.

here is my http post method

$scope.SubmitData = function(AccId)
 {
   $scope.PostData = "REFRESH " + $scope.stbno + ""
   console.log($scope.PostData)
   $http(
   {
     method: 'POST',
     url: 'http://' + $scope.hostUrl + '/DuoSubscribe5/V5Services/V5CAS/Decomposer/ShortMessageExecutor.svc/json/ExecuteShortMessage',
     data:
     {
       "text": $scope.PostData,
       "fromNumber": $scope.FromNumber,
       "toNumber": $scope.ToNumber,
       "securityToken": $scope.stoken
     },
     headers:
     {
       'Content-Type': 'application/json; charset=utf-8'
     }
   }).success($mdDialog.show($mdDialog.alert().parent(angular.element(document.body)).title('Successfully Send').content().ariaLabel('Alert Dialog Demo').ok('OK').targetEvent())).error($mdDialog.show($mdDialog.alert().parent(angular.element(document.body)).content('Refresh failed...').ariaLabel('Alert Dialog Demo').ok('OK').targetEvent()));
 }

here i'm using ui-route to navigate through pages

 .config(['$httpProvider', '$stateProvider', '$urlRouterProvider', function(httpProvider, $stateProvider, $urlRouterProvider) {
      $urlRouterProvider.otherwise('/Add_Refresh');
      $stateProvider
        .state('Add_Refresh', {
          url: '/Add_Refresh',
          templateUrl: 'refresh_partial/refresh_add_partial.html',
          controller: 'AppCtrl'
        })
  }])

Upvotes: 0

Views: 6786

Answers (1)

Emir Marques
Emir Marques

Reputation: 2687

In the sucess function the parâmeter is other function. You pass a object.

Change:

$scope.SubmitData = function(AccId)
{
    $scope.PostData = "REFRESH " + $scope.stbno + ""
    console.log($scope.PostData)
    $http({
        method: 'POST',
        url: 'http://' + $scope.hostUrl + '/DuoSubscribe5/V5Services/V5CAS/Decomposer/ShortMessageExecutor.svc/json/ExecuteShortMessage',
        data:
        {
            "text": $scope.PostData,
            "fromNumber": $scope.FromNumber,
            "toNumber": $scope.ToNumber,
            "securityToken": $scope.stoken
        },
        headers:
        {
            'Content-Type': 'application/json; charset=utf-8'
        }
    }).success(
        $mdDialog.show($mdDialog.alert().parent(angular.element(document.body)).title('Successfully Send').content().ariaLabel('Alert Dialog Demo').ok('OK').targetEvent())).error($mdDialog.show($mdDialog.alert().parent(angular.element(document.body)).content('Refresh failed...').ariaLabel('Alert Dialog Demo').ok('OK').targetEvent())
    );
}

To:

$scope.SubmitData = function(AccId)
{
    $scope.PostData = "REFRESH " + $scope.stbno + ""
    console.log($scope.PostData)
    $http({
        method: 'POST',
        url: 'http://' + $scope.hostUrl + '/DuoSubscribe5/V5Services/V5CAS/Decomposer/ShortMessageExecutor.svc/json/ExecuteShortMessage',
        data:
        {
            "text": $scope.PostData,
            "fromNumber": $scope.FromNumber,
            "toNumber": $scope.ToNumber,
            "securityToken": $scope.stoken
        },
        headers:
        {
            'Content-Type': 'application/json; charset=utf-8'
        }
    }).success(function(res){
        $mdDialog.show($mdDialog.alert().parent(angular.element(document.body)).title('Successfully Send').content().ariaLabel('Alert Dialog Demo').ok('OK').targetEvent())).error($mdDialog.show($mdDialog.alert().parent(angular.element(document.body)).content('Refresh failed...').ariaLabel('Alert Dialog Demo').ok('OK').targetEvent())
    });
}

Upvotes: 1

Related Questions