且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AngularJS - $http.post 将数据作为 json 发送

更新时间:2022-03-29 05:24:35

使用 JSON.stringify() 来包装你的 json

Use JSON.stringify() to wrap your json

var parameter = JSON.stringify({type:"user", username:user_email, password:user_password});
    $http.post(url, parameter).
    success(function(data, status, headers, config) {
        // this callback will be called asynchronously
        // when the response is available
        console.log(data);
      }).
      error(function(data, status, headers, config) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.
      });