Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular Js Routing generate "XMLHttpRequest cannot load" Error in Google chrome #6

Open
vinothstce opened this issue Nov 5, 2014 · 1 comment

Comments

@vinothstce
Copy link

Both basic routing example and the one which include html on page without reloading generates the error given below in Google Chrome, code and error are given below...Guide me with solution for same...

index.html

  html ng-app="demoApp"
head
    meta charset="UTF-8"
    titleRoutingtitle
    script src="../angular.min.js"script
    script src="../angular-route.js"script
    script src="app.js"script
head
body
    div ng-viewdiv
body

html

app.js

        var demoApp = angular.module('demoApp', ['ngRoute']);
        demoApp.controller('NameCtrl', function($scope, $http){
            $http.get("../countries.json").success(function(data){
                alert("Hello");
                $scope.countries = data;
            }).error(function(data, status){
                alert("No Hello");
                alert(status);
                $scope.data = data || "Request failed";
                $scope.status = status;
            });
        });
        demoApp.controller('CntryDtlCtrl', function($scope, $routeParams){
            alert($routeParams);
            console.log($routeParams);

        });
        demoApp.config(function($routeProvider){
            $routeProvider
                  .when('/',{
                        template: '<ul><li ng-repeat="entity in countries">{{entity.country}}</li></ul>',
                        controller: 'NameCtrl'
                  }).
                  when('/:country',{
                    // Add # with a name i.e country name in the url to get this content eg. file:///Users/karthicklove/Documents/Aptana%20Studio%203%20Workspace/Object_Javascript/Angular_Js/50_examples/Routing/index.html#/china
                    template: '<h1>TODO create country detail view<h1>',
                    controller: 'CntryDtlCtrl'
                  }).
                  otherwise({
                    redirectTo: '/'
                  });
        });

Error: "XMLHttpRequest cannot load file://localhost/Users/karthicklove/Documents/Aptana%20Studio%203%20Workspace/Object_Javascript/Angular_Js/50_examples/countries.json. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource. "

@Alok255
Copy link

Alok255 commented Aug 29, 2017

angular.min.js:86 XMLHttpRequest cannot load

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants