$ http.post成功回调未在angularJS中执行

时间:2014-06-10 10:17:27

标签: javascript ajax angularjs mongodb

我正在尝试使用mongoDb$http.post()数据库中发布数据并调用成功回调。但是回调没有执行,数据也没有添加到db。我正在使用mongodblabs来吊起数据库。

代码

if (user) { 
$http.post('https://api.mongolab.com/api/1/databases/expensesharer/collections/expensesharer?apiKey=<apikey>', {"id": user.id, "pwd": user.pwd}).success(
  function (data, status, headers) {
      alert("Added", data, status, headers);
  });  
}                                                                                                                           

1 个答案:

答案 0 :(得分:0)

添加错误回调

if (user) { 
    $http.post('https://api.mongolab.com/api/1/databases/expensesharer/collections/expensesharer?apiKey=<apikey>', {"id": user.id, "pwd": user.pwd}).success(
    function (data, status, headers) {
        alert("Added", data, status, headers);
    }).error(function(data, status, headers, config) {
        alert("Error");
    };  
}
相关问题