Getting the below error:
OPTIONS http://localhost:4444/Examples/Form net::ERR_CONNECTION_REFUSED
The Angular JS code used:
var app = angular.module('myApp', []);
app.controller('myCtrl', ['$scope', '$http', function($scope, $http) {
var enrolledUser = {};
$scope.enrolledUser = enrolledUser;
console.log("Func");
$scope.sendPost = function(){
console.log("Func Called");
$http.post('http://localhost:4444/Examples/Form',enrolledUser);
};
}]);
HTML Code:
<div ng-controller='myCtrl'>
<form name="enrollform" class="css-form" novalidate >
<label for="empNo">Employee Number* :</label>
<input type="text" ng-model="enrolledUser.empNo" name="empNo" ng-required/>
<span ng-show="enrollform.empNo.$error.required">Employee Number is mandatory!!</span>
<button type="button" class="btn btn_success" ng-click="sendPost()">Submit</button>
</form>
Detailed Error received on console:
angular.js:12759 OPTIONS http://localhost:4444/Examples/Form net::ERR_CONNECTION_REFUSED
angular.js:14700 Possibly unhandled rejection:{"data":null,"status":-1,"config":{"method":"POST","transformRequest":[null],"transformResponse":null], "jsonpCallbackParam":"callback","url":"http://localhost:4444/Examples/Form","data":{"empNo":"1","track":"1","designation":"SE","category":"UI","subCategory":"AngularJS"},"headers":{"Accept":"application/json, text/plain, /","Content-Type":"application/json;charset=utf-8"}},"statusText":"","xhrStatus":"error"}