AngularJS | AJAX - $http Last Updated : 27 Jun, 2019 Comments Improve Suggest changes 5 Likes Like Report The AngularJS provides a control service named as AJAX - $http, which serves the task for reading all the data that is available on the remote servers. The demand for the requirement of desired records gets met when the server makes the database call by using the browser. The data is mostly needed in JSON format. This is primarily because for transporting the data, JSON is an amazon method and also it is straightforward & effortless to use within AngularJS, JavaScript, etc. Syntax: function studentController($scope,$https:) { var url = "data.txt"; $https:.get(url).success( function(response) { $scope.students = response; }); } Method: There are lots of methods that can be used to call $http service, this are also shortcut methods to call $http service. .post() .get() .head() .jsonp() .patch() .delete() .put() Properties: With the help of these properties, the response from the server is an object. .headers : To get the header information (A Function). .statusText: To define the HTTP status (A String). .status: To define the HTTP status (A Number). .data: To carry the response from the server (A string/ An Object). .config: To generate the request (An Object). Example: First of all, we will have a file which is going to contain our data. For this example, we have the file data.txt, which will include the records of the student. An ajax call will be made by the $http service. It is going to divert & set the response to the students having priority. After this extraction, the tables will be drawn up in the HTML, which will be based on the students model. The data.txt file: [ { "Name" : "Ronaldo", "Goals" : 128, "Ratio" : "69%" }, { "Name" : "James", "Goals" : 007, "Ratio" : "70%" }, { "Name" : "Ali", "Goals" : 786, "Ratio" : "99%" }, { "Name" : "Lionel ", "Goals" : 210, "Ratio" : "100%" } ] Code: html <!DOCTYPE html> <html> <head> <title>AngularJS AJAX - $http</title> <style> table, th, td { border: 1px #2E0854; border-collapse: collapse; padding: 5px; } table tr:nth-child(odd) { background-color: #F6ADCD; } table tr:nth-child(even) { background-color: #42C0FB; } </style> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"> </script> </head> <body> <center> <h1 style="color:green">GeeksforGeeks</h1> <h3>AJAX - $http</h> <div ng-app="" ng-controller="studentController"> <table> <tr> <th>Name</th> <th>Goals</th> <th>Ratio</th> </tr> <tr ng-repeat="student in students"> <td>{{ Player.Name }}</td> <td>{{ Player.Goals}}</td> <td>{{ Player.Ratio}}</td> </tr> </table> </div> <script> function studentController($scope, $http) { var url = "/data.txt"; $http.get(url).then( function(response) { $scope.students = response.data; }); } </script> </center> </body> </html> Output: Create Quiz Comment S SohomPramanick Follow 5 Improve S SohomPramanick Follow 5 Improve Article Tags : AngularJS Explore AngularJS BasicsAngularJS Tutorial 5 min read Introduction to AngularJS 4 min read Angular CLI | Angular Project Setup 3 min read AngularJS Expressions 2 min read AngularJS Modules 3 min read AngularJS ng-model Directive 4 min read AngularJS Data Binding 4 min read AngularJS Controllers 3 min read AngularJS | Scope 2 min read AngularJS Services 4 min read AngularJS | AJAX - $http 3 min read AngularJS | Tables 2 min read AngularJS Select Boxes 2 min read AngularJS SQL 3 min read AngularJS HTML DOM 2 min read AngularJS Events 3 min read AngularJS | Forms 3 min read AngularJS Form Validation 3 min read AngularJS | API 2 min read AngularJS and W3.CSS 2 min read AngularJS Includes 3 min read AngularJS Animations 1 min read AngularJS | Application 3 min read AngularJS DirectivesAngularJS Directives 9 min read AngularJS ng-app Directive 1 min read AngularJS ng-bind Directive 2 min read AngularJS ng-bind-html Directive 2 min read AngularJS ng-bind-template Directive 2 min read AngularJS ng-blur Directive 1 min read AngularJS ng-change Directive 2 min read AngularJS ng-checked Directive 2 min read AngularJS ng-class Directive 2 min read AngularJS ng-class-even Directive 2 min read AngularJS ng-class-odd Directive 2 min read AngularJS ng-click Directive 2 min read AngularJS ng-cloak Directive 2 min read AngularJS ng-controller Directive 2 min read AngularJS Directives Complete Reference 2 min read AngularJS FiltersAngularJS | Filters 7 min read AngularJS currency Filter 2 min read AngularJS | date Filter 2 min read AngularJS filter Filter 3 min read AngularJS json Filter 2 min read AngularJS limitTo Filter 2 min read AngularJS lowercase Filter 1 min read AngularJS number Filter 1 min read AngularJS orderBy Filter 4 min read AngularJs uppercase Filter 1 min read AngularJS Converting FunctionsAngularJS angular.lowercase() Function 2 min read AngularJS angular.uppercase() Function 1 min read AngularJS angular.forEach() Function 1 min read AngularJS Comparing FunctionsAngularJS angular.isArray() Function 2 min read AngularJS angular.isDate() Function 2 min read AngularJS angular.isDefined() Function 2 min read AngularJS angular.isElement() Function 2 min read AngularJS angular.isFunction() Function 2 min read AngularJS angular.isNumber() Function 2 min read AngularJS angular.isObject() Function 2 min read AngularJS | angular.isString() Function 1 min read AngularJS angular.isUndefined() Function 2 min read AngularJS angular.equals() Function 2 min read AngularJS angular.toJson() Function 2 min read AngularJS QuestionsHow to bundle an Angular app for production? 4 min read How to add many functions in one ng-click directive? 2 min read How to directly update a field by using ng-click in AngularJS ? 3 min read How to Add Dynamic Options for Multiple Selects Inside ng-repeat Directive ? 3 min read How to detect when an @Input() value changes in Angular? 3 min read How to open popup using Angular and Bootstrap ? 2 min read How to reload or re-render the entire page using AngularJS? 2 min read How to add input fields dynamically on button click in AngularJS ? 2 min read How to Create Button Dynamically with Click Event in Angular ? 2 min read How to use jQuery in Angular ? 2 min read AngularJS Examples 2 min read Like