无法获取内部响应。成功[AngularJs$http.get..]
我在jsp文件中调用函数无法获取内部响应。成功[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.
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)打印:::[对象]