我的代码就像这样
$http.post("../services/myurl.aspx?Param=" + finaldata, '', { 'Content-type': 'text' })
.success(function (pricedata) {
alert (success)
})
.error(function () {
alert('we have failed to make a connection with the server. Please try after some time');
});
当我进行此调用时,既不会成功也不会发生错误。但是调用该服务。我有点困惑。谁能指出我做错了什么?
答案 0 :(得分:0)
你应该使用服务来发布数据,这是你可以做到的。
doSomething: function (data, url) {
return $http({
url: url,
method: 'POST',
data: data
});
},
并在您的控制器中将此服务用作
someService.doSomething($scope.MyData, $scope.Url)
.success(function (response) {
console.log("Success", response);
})
.error(function (data, status, headers, config) {
console.log("Error");
});
答案 1 :(得分:0)
试试这个简单的代码......
$http({
method: 'POST',
url: "../services/myurl.aspx?Param=" + finaldata,
})
.success(function (data, status, headers, config) {
var success="success"
alert (success);// or alert("success")
})
.error(function (data, status, headers, config) {
alert('we have failed to make a connection with server. Please try after some time');
});