首先,我已经看到了很多资源并尝试了它们,但没有运气。
我试图通过发布两个变量从节点服务器获取一些数据。
注意:如果可能的话,我宁愿不使用JQuery
我认为问题在于:
var data = {
"username": "trumpt",
"offset": "0"
};
这是一个小提琴 http://jsfiddle.net/pa21anen/
编辑:
我得到的输出为{"errors":"Invalid Input"}
,但它应该是相同的url和数据和请求类型。我已经在android,ios,windows 10 apps
{
"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 :(得分:1)
这就是如何在没有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