0

When I click on a button it will go to controller and hit the server through API and return the data into the html page.
I have created my own API and placed in Cloud I am accessing it through web address, I am not using any other sites api. The code which I written is hitting the server through API but the data is not displaying.

My HTML Code

<body ng-app="MyApp">
    <div ng-controller="testctrl">
        <button ng-click="loadtestctrl()">Load ctrl</button>
        {{result}}

    </div>

My Controller Code

app.controller("testctrl",function($scope,$http){
            $scope.loadtestctrl = function(){
                $http.get("http://192.168.0.103:8081/kunera-pos/franchise/getFranchise/").then(function(response){
                    $scope.result = response.data;
                });
            }

        });

The three Error which I am getting are
Error 1

Failed to load resource: the server responded with a status of 404 (Not Found)

Error 2

XMLHttpRequest cannot load http://192.168.0.103:8081/kunera-pos/franchise/getFranchise/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

Error 3

Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"http://192.168.0.103:8081/kunera-pos/franchise/getFranchise/","headers":{"Accept":"application/json, text/plain, /"}},"statusText":""}

I cant find out where I am making mistake.
I am using Angularjs CDN 1.6.5
Thanks in Advance

gopal
  • 3
  • 4
  • Possible dupe of this https://stackoverflow.com/questions/23823010/how-to-enable-cors-in-angularjs – acostela Aug 23 '17 at 10:33
  • 3
    Possible duplicate of [How to enable CORS in AngularJs](https://stackoverflow.com/questions/23823010/how-to-enable-cors-in-angularjs) – acostela Aug 23 '17 at 10:33

0 Answers0