我在angularjs控制器中使用$.ajax
来保存订单。在我更新到AngularJS 1.2.2后,我在调用TypeError: Cannot call method 'then' of undefined
时收到错误$.ajax
。我找不到任何有关改变的信息。难道我做错了什么?这是我的ajax调用代码:
$scope.saveOrder = function () {
$.ajax({
type: 'POST',
url: $scope.saveOrderUrl,
data: $scope.order,
async: false,
dataType: 'json',
success: function (result) {
$scope.order = result;
$scope.isNewOrder = false;
if ($scope.order.OrderId === 0) {
alert("No order id was returned from the server. The order will not be opened in view mode.");
window.location.href = appUrl + "/Order/Index/" + $scope.patientId;
} else {
window.location.href = appUrl + "/Order/Details/?personId=" + $scope.patientId + "&orderId=" + $scope.order.OrderId;
}
},
error: function (xhr, status, error) {
alert("Error when saving order. Status: " + status);
}
});
}
答案 0 :(得分:1)
$.ajax
是jQuery(或Angular jQuery lite实现)ajax方法。要获得Angular的承诺,您需要使用$http
(注意$
之后的缺席。