$ http.post请求时抛出Angular错误对象

时间:2014-08-05 17:44:16

标签: ajax angularjs

我正在设置一个新的角度应用程序,并且在我尝试使用$ http进行ajax请求时遇到了一个奇怪的错误。

我有以下代码:

srnApp.controller('WallCtrl', [
    '$scope', '$http',
    function($scope, $http) {
        $http.post('/api',  {
            "method":"wallStuff"
        }).success(function(data, status, headers, config) {
            console.log("SUCCESS retrieving wall: \n", data);
        }).error(function(data, status, headers, config) {
            console.log("ERROR getting wall: \n", data, status, headers, config);
        });
]);

每次发出请求时,我都会在调用错误回调之前获得以下错误对象:

Exception { 
    message: "", 
    result: 2153644038, 
    name: "", 
    filename: "myServer.net/js/angular.min.js", 
    lineNumber: 78, 
    columnNumber: 0, 
    inner: null, 
    data: null 
}

这究竟是什么意思,我该如何解决它?

1 个答案:

答案 0 :(得分:1)

我弄明白了这个问题。我的资源与提供js的地方不同,因此浏览器不允许该请求。我通过更改一些服务器端来解决这个问题。