2016-02-25 3 views
0

Прежде всего, я видел много ресурсов и пробовал их, но не повезло.Простой Угловой запрос на отправку ошибки

Я пытаюсь получить некоторые данные с узла сервера, разместив две переменные.

Примечание: Я предпочел бы не использовать JQuery, если это возможно

Я думаю, что проблема здесь:

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

здесь скрипку http://jsfiddle.net/pa21anen/

Edit: я набираюсь вывод как {"errors":"Invalid Input"}, но он должен быть с тем же URL-адресом и данными и типом запроса. Я успешно реализовал его в андроиде, IOS, Windows 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

Я проверил его, но я не могу знать со скрипки, если это проблема сервера или нет (вы можете добавить к серверному коду, это может помочь) –

ответ

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

+0

работает для меня ... отлично –

Смежные вопросы