Angularjs Post请求在angular js项目中未成功? **这是我的app.js** var-app=angular.module(“app”,[]); app.controller(“HttpGetController”,函数($scope,$http){ $scope.SendData=函数(){ //使用$.param jQuery函数从JSON序列化数据 变量数据=$.param({ fName:$scope.firstName, lName:$scope.lastName }); 变量配置={ 标题:{ “内容类型”:“application/x-www-form-urlencoded;charset=utf-8;” } } $http.post('/PostRequest/RequestForm.html',数据,配置) .success(函数(数据、状态、标题、配置){ $scope.PostDataResponse=数据; }) .错误(功能(数据、状态、标题、配置){ $scope.ResponseDetails=“数据:”+数据+ “状态:”+状态+ “标题:”+标题+ “配置:”+config; }); }; }); **这是我的html**

Angularjs Post请求在angular js项目中未成功? **这是我的app.js** var-app=angular.module(“app”,[]); app.controller(“HttpGetController”,函数($scope,$http){ $scope.SendData=函数(){ //使用$.param jQuery函数从JSON序列化数据 变量数据=$.param({ fName:$scope.firstName, lName:$scope.lastName }); 变量配置={ 标题:{ “内容类型”:“application/x-www-form-urlencoded;charset=utf-8;” } } $http.post('/PostRequest/RequestForm.html',数据,配置) .success(函数(数据、状态、标题、配置){ $scope.PostDataResponse=数据; }) .错误(功能(数据、状态、标题、配置){ $scope.ResponseDetails=“数据:”+数据+ “状态:”+状态+ “标题:”+标题+ “配置:”+config; }); }; }); **这是我的html**,angularjs,Angularjs,名字: 名字: 提交 {{PostDataResponse}} {{ResponseDetails}} 我在eclipse中创建了一个dynamicwebproject 我不知道我是否在post请求中传递了正确的url。我将Requestfrom.html作为输出。请告诉我如何解决此问题以及如何传递正确的url。这是您的服务器路径“/PostRequest/RequestForm.html”?您的doctype和html标记在哪里?浏览器的“网络”选项卡中发生了什么?发帖了吗?很抱歉迟到了

名字:

名字:

提交
{{PostDataResponse}} {{ResponseDetails}}
我在eclipse中创建了一个dynamicwebproject
我不知道我是否在post请求中传递了正确的url。我将Requestfrom.html作为输出。请告诉我如何解决此问题以及如何传递正确的url。

这是您的服务器路径“/PostRequest/RequestForm.html”?您的doctype和html标记在哪里?浏览器的“网络”选项卡中发生了什么?发帖了吗?很抱歉迟到了。我不知道服务器路径。我已经按照你刚才说的假设路径发了。请告诉我如何找到服务器路径
**Here is my app.js**
 var app = angular.module("app", []);
    app.controller("HttpGetController", function ($scope, $http) {

        $scope.SendData = function () {
           // use $.param jQuery function to serialize data from JSON 
            var data = $.param({
                fName: $scope.firstName,
                lName: $scope.lastName
            });

            var config = {
                headers : {
                    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                }
            }

            $http.post('/PostRequest/RequestForm.html', data, config)
            .success(function (data, status, headers, config) {
                $scope.PostDataResponse = data;
            })
            .error(function (data, status, header, config) {
                $scope.ResponseDetails = "Data: " + data +
                    "<hr />status: " + status +
                    "<hr />headers: " + header +
                    "<hr />config: " + config;
            });
        };

    });

**here is my html**
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src = "js/app.js"></script>
<script src = "js/jquery.js"></script>
<body>
<div ng-app="app" ng-controller="HttpGetController">
    <p>First Name: <input type="text" name="firstName" ng-model="firstName" required /></p>
    <p>First Name: <input type="text" name="lastName" ng-model="lastName" required /></p>
    <button ng-click="SendData()">Submit</button>
    <hr />
    {{ PostDataResponse }}
    {{ ResponseDetails }}
</div>
</body>