获得以下错误:
OPTIONS http://localhost:4444/Examples/Form net::ERR_CONNECTION_REFUSED
使用的Angular JS代码:
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代码:
<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>
在控制台上收到详细错误:
angular.js:12759选项http://localhost:4444/Examples/Form 净:: ERR_CONNECTION_REFUSED
angular.js:14700可能未处理 抑制:{&#34;数据&#34;:空,&#34;状态&#34;: - 1,&#34;配置&#34; {&#34;方法&#34;:&#34; POST& #34;&#34; transformRequest&#34;:[空],&#34; transformResponse&#34;:空], &#34; jsonpCallbackParam&#34;:&#34;回调&#34;&#34; URL&#34;:&#34; http://localhost:4444/Examples/Form&#34;&#34;数据&#34 ;: {&#34; EMPNO&#34;:&#34; 1&#34;&#34;跟踪&#34;:&#34; 1&#34;&#34;指定&#34;:&#34; SE&#34;&#34;类别&#34;:&#34; UI&#34;&#34;子类别&#34;:&#34; AngularJS&#34;}&#34;头&#34; :{&#34;接受&#34;:&#34;应用/ JSON, text / plain的, / &#34;&#34;内容类型&#34;:&#34;应用/ JSON;字符集= UTF-8&#34;}},&#34;状态文本&#34 ;:&#34;&#34;&#34; xhrStatus&#34;:&#34;错误&#34;}