Angular JS $http service use

Source: Internet
Author: User
Tags http post

$http can be used to get data on a Web service, or to pass a JSON server over a POST request

The main use of the $http.get () and post () two methods.

$http. Get () Gets the data to the server through a GET method. Main methods of Use:

1. The first form of notation

$http. Get (URL)

. seccess (function (response)

{

Todo

})

. Error (function (Exception)

{

Todo

});

2. The second type of notation

$http (

{
Method: ' GET ',
URL: '/api/users.json ',
params:{
' username ': ' Tan '
});

$http Post method is possible to transfer data to the server, if you do not set the upload format, the default is the use of JSON, the main way to use:

$http (

{
URL: ' Http://localhost:8080/user/register ',
Method: ' POST ',
Data: ' {' name ': ' Jimmy ', ' Age ': 12} '
})

. Success (function (data)

{
alert (data);
});

Data can be a string or an object

Angular JS $http service use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.