I am currently studying AngularJS and I suspect there may be a glitch in my page.
On the page, there is a TEXTAREA where I have typed 'aaa'. The TEXTAREA is linked to an ng-model named input. The following AngularJS code aims to monitor external changes and periodically save data to the server:
var UnixyTalk = angular.module('UnixyTalk', []);
UnixyTalk.controller('OutputController', ['$scope','$http', '$timeout', '$q',
function($scope, $http, $timeout, $q)
{
var last_input = $scope.input;
var repeatEr = function(data, status, headers, config)
{
var interval = !(config && config.time)? 1000 :
(1000 - (config.time - (new Date()).getTime()));
angular.extend($scope, data);
console.log(data);
$timeout(function()
{
$http.post('/ajax/listen',
{
'cache': false,
'params': {'conversation': 0},
'timeout': 1000,
}).success(repeatEr).error(repeatEr);
$http.post('/ajax/say',
{
'conversation': 0,
'params': {'text': $scope.input, 'time': new
Date().getTime()}
});
}, interval);
}
repeatEr();
}
]);
The server side is indicating that it is receiving an empty POST dictionary.
If I want to post key-value pairs in the format of a QUERY_STRING (e.g. 'field1=value1&field2=value2') rather than a JSON object, how should I structure the dictionary? Are there any other mistakes in this code?
Appreciate your help,