来自我的角度应用程序的网络服务。我正在使用http post方法。因此,当我调用该服务时,它会回复,但另外我会得到" Argument' fn'不是一个功能,得到了对象" Chrome控制台中的错误。
这是我的http post方法
$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()));
}
这里我使用ui-route浏览页面
.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'
})
}])
答案 0 :(得分:1)
在成功功能中,参数是其他功能。您传递了一个对象。
变化:
$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())
);
}
要:
$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())
});
}