简单的角度帖子请求返回错误

问题描述:

首先,我看到了很多资源,并尝试过但没有运气。简单的角度帖子请求返回错误

我想通过发布两个变量从节点服务器获取一些数据。

注意:我宁愿不使用JQuery如果可能的话

我认为这个问题是在这里:

var data = { 
     "username": "trumpt", 
     "offset": "0" 
     }; 

这里是一个小提琴 http://jsfiddle.net/pa21anen/

编辑: 我收到输出为{"errors":"Invalid Input"},但它应该是具有相同的URL和数据和请求类型。我已经成功地实现了它在Android,iOS设备的窗口10应用

{ 
    "notifications": [ 
    { 
     "id": 1, 
     "sender": "trumpt", 
     "title": "test 1", 
     "body": "Hello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticonHello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticonHello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticon\nHello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticon", 
     "priority": 3, 
     "time": 1455503708, 
     "type": 1, 
     "attachments": "image458286.jpg,pdf-sample.pdf,sample.doc,SampleGrades.xls" 
    }, 
    { 
     "id": 2, 
     "sender": "trumpt", 
     "title": "test 2", 
     "body": "another test notif", 
     "priority": 1, 
     "time": 1455474927, 
     "type": 1, 
     "attachments": "oimage458286.jpg" 
    }, 
    { 
     "id": 3, 
     "sender": "trumpt alter", 
     "title": "test by new user", 
     "body": "just a frickin' test", 
     "priority": 2, 
     "time": 1455478746, 
     "type": 1, 
     "attachments": null 
    } 
    ] 
} 
+0

问题的本质究竟是什么? “没有运气”是不够的,我们理解这个问题 –

+0

检查小提琴请 –

+0

我检查了它,但我不知道从小提琴是否是服务器问题或不(你可以添加到服务器端代码,它可能会帮助) –

这是这样,你怎么可以序列化数据,而不JQuery的在AngularJS张贴到服务器。

.controller('myCtrl', function($scope, $http, $httpParamSerializerJQLike) { 
    $scope.SendData = function() { 

     var data = { 
     "username": "trumpt", 
     "offset": "0" 
     }; 

     $http({ 
      method: 'POST', 
      url: 'https://trumpt-nigharsh.c9users.io/notifications/getAll', 
      data: $httpParamSerializerJQLike(data), 
      headers: {'Content-Type': 'application/x-www-form-urlencoded'} 

     }).success(function(data, status, headers, config) { 
      $scope.PostDataResponse = data; 
     }) 
     .error(function(data, status, header, config) { 
      $scope.PostDataResponse = data 
     }); 
    }; 

工作样本这里:https://plnkr.co/edit/Wp3dj6FBIq09V3tbDPV0?p=preview

NB!这个序列化仅在一些后者的AngularJS版本中引入。测试1.4.8 编辑: 短版POST:https://plnkr.co/edit/EGXIBJV24H0u7QO8JYEX?p=preview

+0

为我工作...伟大 –