Hi,
I want to hit the web service which is created by server side and url I know for it and retrieve the json data if it is successful otherwise message should be failure. so how I should hit service using Ajax in AngularJs.The foll code I wrote Pls tell me any changes to be made OR any other way I should write the code
THIS CODE IS OF JAVASCRIPT
angular.module('myModule', [])
.service('ajaxRequest', function (url,data,successFn,errorFn,$http) { })
.controller('myController', ['ajaxRequest', function (url,data,successFn,errorFn,$http)
{$http({ url:
http://url of server side,
method: "POST",
dataType:'json',
data:{ empID:"1254556",
password:"Pass",
deviceId:"abc",
}
}).success(successFn).error(errorFn);
successFn(data)
{
alert(data);
}
errorFn(error)
{
alert(error);
}
}]);
AND HTML PAGE IS
<!doctype html>
<html>
<script src=serviceController.js></script> and included angular min js file
<body ng-app="myModule" ng-controller="myController">
</body>
</html>