Reputation: 138
I am trying to use normal jQuery Ajax in anuglarjs .
$.ajax({
type: "POST",
url: window.apirooturl + "/logger",
contentType: "application/json",
data: angular.toJson({
url: $window.location.href,
message: errorMessage,
type: "exception",
stackTrace: stackTrace,
cause: ( cause || "")
})
});
But i am getting an error
Below two messages appears in the firbug
Do we need to configure something to use normal jquery function in anagularjs? I tried to look on Google but could not get a answer
More information : I am trying to send client side error to the server side and trying to implement a global exception handler as suggested in this post . http://www.bennadel.com/blog/2542-logging-client-side-errors-with-angularjs-and-stacktrace-js.htm
Upvotes: 0
Views: 1209
Reputation: 460
1) If you reference full jQuery library, Angular should use it instead of it's own. Do you reference it before angular.js file?
2) Wrap your code with $timeout to prevent error '$digest already in progress'
Upvotes: 0
Reputation: 7475
You are not supposed to use $.ajax in angular you need to use $http request
for example, this is ho you should use post:
$http({
url: "http://example.com",
method: "POST",
data: {"a":"b"}
}).success(function(data, status, headers, config) {
$scope.data = data;
}).error(function(data, status, headers, config) {
$scope.status = status;
});
please see more at : https://docs.angularjs.org/api/ng/service/$http
Upvotes: 1