javascript - Why won't $http.put in AngularJS work? -


i have following angular script in page:

var app = angular.module('doorman', []);  app.controller('formctrl', function($scope, $http) {    $scope.create = function() {      var msg = '{' +        '"id":"id",' +        '"building":"' + $scope.building + '",' +        '"unit":"' + $scope.unit + '",' +        '"firstname":"' + $scope.firstname + '",' +        '"name":"' + $scope.name + '",' +        '"carrier":"' + $scope.carrier + '",' +        '"tracker":"' + $scope.tracker + '"' +        '"delivered":"0",' +        '"added":"now()"' +        '}';      $http.put("104.131.166.246:8080/doorman/rest/pilot", msg).      success(function(data, status, headers, config) {        //empty fields        $scope.building = "";        $scope.unit = "";        $scope.firstname = "";        $scope.name = "";        $scope.carrier = "";        $scope.tracker = "";      }).      error(function(data, status, headers, config) {        //todo temporary, remove        alert("error " + status + ": " + data);      });    };    $scope.search = function() {      }  });

i have backend restful java servlet handling requests. when call 'create()' function, output ends on error function, showing alert 'error undefined: undefined'. while monitoring http requests on chrome, see no request being made @ all. problem be?

from angular side, code looks ok. further when call ends in error section, suggest going wrong on outbound call or on server side. can use browser tools or if in windows use tool fiddler see network traffic see what’s going on. 1

other thing, see whether have enable cross-origin resource sharing (cors) on server side.

cheers


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -