0

I have a static json file at http:///test.json, which I can view in my browser just fine.

I'm trying to use $http.get to load that json file. Here's my code in :

        testApp.run(function ($http) {
        $http.get("test.json")
            .success(function (data, status, headers, config) {
                alert("Yay!");
            })
            .error(function (data, status, headers, config) {
                alert("Fail!");
            });
        });

Any suggestions? Get is definitely being called as it's giving me the Fail alert. This must be easy but it's driving me crazy.

pscuderi
  • 1,554
  • 12
  • 14

1 Answers1

0

Try with / on the URL for the GET method like this:

$http.get("/test.json")
            .success(function (data, status, headers, config) {
                alert("Yay!");
            })
            .error(function (data, status, headers, config) {
                alert("Fail!");
            });
        });
Dalorzo
  • 19,834
  • 7
  • 55
  • 102