AngularJS - $http.post send data as json

后端 未结 3 1803
野的像风
野的像风 2020-12-05 06:19

I\'m working on autocomplete directive with angularjs but having some issues.

I have a form which have an autocomplete input. When i type something there, the

3条回答
  •  误落风尘
    2020-12-05 07:10

    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.
          });
    

提交回复
热议问题