Trending News
Home / Web Development / Angular Js / AngularJS – Ajax

AngularJS – Ajax

The $http service helps to call the ajax request in angularjs. The $http service in angular js helps to perform http request. It also allows you create any http request by just injecting it via controller constructor.
It also helps to fetch the data from remote server. It needs the data available at the server must be in JSON format or an javascript object. $http fetches the data from the server using browser.

In AngularJS you can send AJAX requests in several different ways. These are:

  • AJAX calls via the $http service.
  • JSONP calls via the $http service.
  • REST type calls.




Syntax of $http:

Method: GET and POST methods.





Syntax

url: In here we define the url where we fetch the data. We get the data from this specified url.





Syntax

successCallback: This finction will get called when our server returns response.

Syntax




errorCallback: This function will get called when server returns error.

Syntax

Loading Facebook Comments ...
Social Media Auto Publish Powered By : XYZScripts.com