angularJS请求参数 ajax

1. 使用angular服务请求

app.controller('main', function($scope, $http) {
    $scope.fun1 = function () {
        $http({
            method:'POST',
            url:'/user/addUser',
            {#params:{name:'admin',age:21},#}
            data:{name:'admin',age:22},
            dataType:'json',
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }
        }).then(function (response) {
             console.log(response.data)
        }, function (response) {
            // 请求失败执行代码
        });

    }
});

end

猜你喜欢

转载自www.cnblogs.com/zhuxiang1633/p/10060176.html
今日推荐