Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法获取内部响应。成功[AngularJs$http.get..]_Angularjs - Fatal编程技术网

无法获取内部响应。成功[AngularJs$http.get..]

无法获取内部响应。成功[AngularJs$http.get..],angularjs,Angularjs,我在jsp文件中调用函数continueform(),并在控制器中定义了它。但是程序没有输入angResponse.success,而是进入angResponse.error下。有人能在这里指出这个问题吗?另外,如何确保angResponse接收从validateForm jsp传递的JSON对象 JSP文件: button ng-click=continueform() **Inside Controller:** angular.module.controller . . $scope.

我在jsp文件中调用函数
continueform()
,并在控制器中定义了它。但是程序没有输入angResponse.success,而是进入angResponse.error下。有人能在这里指出这个问题吗?另外,如何确保
angResponse
接收从validateForm jsp传递的JSON对象

JSP文件:

button ng-click=continueform()

**Inside Controller:**

angular.module.controller
.
.
$scope.continueform = function(){
    var angResponse = $http.get("/validateForm.jsp"); //relative path
    angResponse.success(function(data) {
    // do something
    });
    angResponse.error(function(data) {
    // do something
    });
}
JSONObject allContent = new JSONObject();
Map currAddressMap = new HashMap();
currAddressMap.put("current_add", "123");
currAddressMap.put("current_city", "xyz");
allContent.put("current_address", new JSONObject(currAddressMap));
validateForm.jsp:

button ng-click=continueform()

**Inside Controller:**

angular.module.controller
.
.
$scope.continueform = function(){
    var angResponse = $http.get("/validateForm.jsp"); //relative path
    angResponse.success(function(data) {
    // do something
    });
    angResponse.error(function(data) {
    // do something
    });
}
JSONObject allContent = new JSONObject();
Map currAddressMap = new HashMap();
currAddressMap.put("current_add", "123");
currAddressMap.put("current_city", "xyz");
allContent.put("current_address", new JSONObject(currAddressMap));

当您调用/validateForm.jsp时,“网络”选项卡(在浏览器开发工具中)会说什么?如果它遇到了.error回调,那么您的服务器可能不会返回HTTP 200代码。使用fiddler或其他工具。如果在var angResponse=$http.get(“/validateForm.jsp”)之后执行console.log(angResponse),会得到什么;调用/validateForm时,我得到的结果是:::{“当前地址”:{“当前城市”:“xyz”,“当前添加”:“123”}}。console.log(angResponse)打印:::[对象]