0

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

  1. $ is not defined
  2. Error: [$rootScope:inprog] $digest already in progress

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

3

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Liad ,There is a circular dependency between the $exceptionHandler and $http thats why i am trying to avoid the use of $http thx
0

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'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.