欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

AngularJS POST GET example

程序员文章站 2022-03-02 13:47:54
...
You can use this in Controller file to use get & post method.
var turtle_data = {Sun:"English"}     
var turtle_url = "http://127.0.0.1:7000/exercise/test/user_data/123/ccy"
$http({
        method:"post",
        url: turtle_url,
        data: turtle_data
    }).
        success(function(data, status) {
            alert(JSON.stringify(data)+'#post#'+status+'#1')
        }).
        error(function(data, status) {
            alert(JSON.stringify(data)+'#post#'+status+'#1')
        });

post

get

$http({
      method: "get",
      url: turtle_url
  }).
      success(function(data, status) {
          alert(JSON.stringify(data)+'#get#'+status+'#0')
      }).
      error(function(data, status) {
          alert(JSON.stringify(data)||"Request failed"+'#get#'+status+'#0')
      });
  


转载于:https://my.oschina.net/coderman/blog/174344