Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am calling one java by using $http in angularjs but I am getting this error in Chrome:

XMLHttpRequest cannot load http://192.168.1.104:8080/etts/Abilityscore?userid=1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

My code is:

var countryApp = angular.module('countryApp', []);
         countryApp.controller('CountryCtrl', function ($scope, $http){
             alert("eee")
           $http.get('http://192.168.1.104:8080/etts/Abilityscore?userid=1
   ').success(function(data) {
             $scope.countries = data;
               var sum = 0; 
               var tval = 0;
               for(var i = 0; i < data.length; i++){
                 sum += parseInt(data[i]['getval'], 10);
                 tval += parseInt(data[i]['totalval'], 10); 


               }
share|improve this question
2  
You are sending request to different domain/port which is not allowed by CORS policy. – Mateusz Nowak Sep 30 '15 at 7:51
1  
As said above - it is not allowed to make cross domain requests unless the requested service allows it. I suggest you read about CORS, saves a lot of hassle in the future - developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS – tiblu Sep 30 '15 at 8:21

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.