Request.HTML - jsFiddle/Gist integration demo

jsFiddle demo hosted on Gist using HTTP Request to get ARES data author(s): Jiri Kubicek

HTML

<script src="/js/empty.js"></script>
<link rel="stylesheet" href="/css/normalize.css">
<div ng-app ng-controller="FetchCtrl">
  ICO: <input type="text" ng-model="ico" ng-change="fetch()" size="80"/><button ng-click="fetch()">fetch</button><br>
  DIC: <input type="text" ng-model="data.dic" size="80"/><br/>
  firma: <input type="text" ng-model="data.firma" size="80"/><br/>
  ulice: <input type="text" ng-model="data.ulice" size="80"/><br/>
  mesto: <input type="text" ng-model="data.mesto" size="80"/><br/>
  psc: <input type="text" ng-model="data.psc" size="80"/><br/>
  
  <pre>http url: {{url}}</pre>                      
  <pre>http status code: {{status}}</pre>
    <pre>form data: {{data}}</pre>
</div>

​

CSS

body {
	font-family: Helvetica, Verdana
}
p {
	padding: 7px 10px;
}
#demo { 
	border: 1px solid #999;
}

JavaScript

function FetchCtrl($scope, $http, $templateCache) {
    $scope.method = 'GET';
    $scope.ico = "67787231";

    $scope.fetch = function() {
        $scope.code = null;
        $scope.data = null;

        $scope.url = "http://www.lepsipraha7.cz/ares.php?ico=" + $scope.ico;

        $http({
            method: $scope.method,
            url: $scope.url,
            cache: $templateCache
        }).success(function(data, status) {
            $scope.status = status;
            $scope.data = data;
        }).error(function(data, status) {
            $scope.data = data || "Request failed";
            $scope.status = status;
        });

    };

}​