AngularJS - 向API发布数据不起作用

时间:2016-08-17 22:57:32

标签: javascript jquery angularjs

我正在尝试将用户放入textarea和文本输入的数据发送到将保存数据的API。

这是功能:

$scope.forward = function() {

  $http({
    url: 'http://appsdev.pccportal.com:8080/ecar/api/reject/' + carID,
    method: "POST",
    data: "comments=" + this.comments,
    data: "recipient=" + this.recipient,
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).
  then(function(response) {
    $scope.output = response.data;
  })

}

运行时它的作用是仅记录收件人而不记录评论。我猜是因为我使用“数据”两次而且它只识别最后一个(在这种情况下是“收件人”)。如何将2个值传递给API。

由于

3 个答案:

答案 0 :(得分:2)

正如您所说,您正在覆盖您传递给IFERROR的普通对象的.mfp-iframe {max-width: 100%;} 密钥,并将其全部发送到一起:

intptr_t

答案 1 :(得分:0)

将其作为对象传递:

X

答案 2 :(得分:0)

这让它工作得很好:

data: 'recipient='+encodeURIComponent(this.recipient)+'&comments='+encodeURIComponent(this.comments),