Hi Jayanta,

This is an CORS issue, because you are making a request on a different 
domain than the script which making the XHR is host on.

You have to put specifics headers on the targeted server to allow CORS 
requests.
Please read http://en.wikipedia.org/wiki/Cross-origin_resource_sharing for 
resolve this issue.

Regards,
Charly.

On Monday, 7 July 2014 14:37:04 UTC+2, Jayanta Pramanik wrote:
>
> Hi,
> We are creating secured web application which is using Angular-JS in web 
> portal. Call to Java REST service is being made from pages. But we can not 
> make the REST call successfully. Here are code snippets for the Java side 
> REST service -
>
> java code::
>
> @Path("/users")
> public class UserRestService {
> @POST
> @Consumes(MediaType.APPLICATION_JSON)
> @Produces(MediaType.APPLICATION_JSON)
> public User create(User user) {
> User user = new User();
> return user ;
> }
> }
>
> angular js code ::
> service.js
> -----------------------
> var consumerREST = angular.module('consumerRESTService', ['ngResource']);
>
> consumerREST.factory('UsersFactory', function ($resource) {
> var services = {
> doCreateUser : $resource('http://localhost:8080/demoApp/service/users', 
> {}, {
> query: { method: 'GET', isArray: true },
> create: { method: 'POST' }
> })
> };
> return services;
> });
>
> controller.js
> ----------------------
> function MyAccountController($scope, $http){
> $scope.insertData = function (UsersFactory) {
> $scope.user = {id:1, firstname: 'AA', lastName: 'CC'};
> UsersFactory.doCreateUser($scope.user);
> }
>
> Error :: Following error is found in Javascript console of the browser -
>
> Cannot read property 'doCreateUser' of undefined
> at Object.MyAccountController.$scope.removeFetchedData1 (
> http://localhost:63342/angular-seed-master/app/js/controllers.js:358:21)
> at Object.MyAccountController.$scope.findAccountInfo (
> http://localhost:63342/angular-seed-master/app/js/controllers.js:334:16)
> .....
> ......
> Please help...
>
> Thanks in advance.
> Regards
> Jayanta Pramanik
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to