Note that there are some explanatory texts on larger screens.

plurals
  1. POAngular Http Get Always Returns Status 0 for ng-click
    primarykey
    data
    text
    <p>I've been trying to get this to work, conceptually its simple click the tag and it calls a REST service that returns a JSON result, where i grab the country name and show it just as a test. I'm using angular. </p> <p>Every time I click it returns with a Status of 0. believe this is the plnker <a href="http://plnkr.co/edit/k3Z6Ufi734oYE4ciVJs8" rel="nofollow">http://plnkr.co/edit/k3Z6Ufi734oYE4ciVJs8</a></p> <p><strong>This is the HTML</strong> not much to it just call the GetInfo function via ng-click</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html ng-app="mainModule"&gt; &lt;!--http://plnkr.co/edit/k3Z6Ufi734oYE4ciVJs8--&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;AngularJS Plunker&lt;/title&gt; &lt;link href="style.css" rel="stylesheet" /&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"&gt;&lt;/script&gt; &lt;script src="app.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body ng-controller="MainCtrl"&gt; &lt;p&gt;Hello {{name}}!&lt;/p&gt; &lt;div&gt;&lt;b ng-click="GetInfo()"&gt;Click Me&lt;/b&gt;&lt;/div&gt; &lt;b&gt;{{AdditionalInfo.geobytescountry}}&lt;/b&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the Angular Back end. </p> <pre><code>var app = angular.module('mainModule', []); app.controller('MainCtrl', function($scope, $http) { $scope.name = 'World'; var cityDetailsUrl = "http://gd.geobytes.com/GetCityDetails?callback=?&amp;fqcn=new%20york,%20NY,%20United%20States"; $scope.AdditionalInfo = {}; $scope.GetInfo = function () { $http.get(cityDetailsUrl) .success(function(data, status, header, config){ console.log('ok'); $scope.AdditionalInfo = data; console.log(data);}) .error(function(data, status, header, config){ console.log('error'); $scope.AdditionalInfo = data; console.log(status);}); } }); </code></pre> <p>the link provided should result in a JSON response as I tried id in the web browser. similar to this "geobytesinternet":"US","geobytescountry":"United States"</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload