Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
1  
Have a look to this question stackoverflow.com/questions/12131659/… –  V31 Jul 14 at 9:00
    
Why are you not using $http? –  Satpal Jul 14 at 9:03
    
I know $http and its is used in project also .But for a specific requirement "logging client side errors to the server" .I am trying to implement as sugguested on this blog engineering.talis.com/articles/client-side-error-logging –  Atul Rai Jul 14 at 9:18

2 Answers 2

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

share|improve this answer
    
Hi Liad ,There is a circular dependency between the $exceptionHandler and $http thats why i am trying to avoid the use of $http thx –  Atul Rai Jul 14 at 9:42

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'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.