Skip to content

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

@vinothstce

Description

@vinothstce

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. "

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions