javascript - AngularJs使用Post为什么后台读不到数据
本文介绍了javascript - AngularJs使用Post为什么后台读不到数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
AngularJs初学者,在使用post时后台没有反应,下面是我的代码
<!doctype html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body >
<div ng-controller="ajaxTest">
<button ng-click="showData(requestType,content)">huoqu</button>
<span>{{data}}</span>
<span>{{error}}</span>
</div>
<script src="ng/angular.js"></script>
<script>
angular.module("myApp",[])
.controller("ajaxTest",function($scope,$http){
$scope.showData = function(requestType,content){
$http.post("http://wuzl-pc:8087/token/doService.do",
{
requestType:"com.bat.shop.token.login",
content:{'mobile':'1','password':'1'}
})
.success(function(data){
$scope.data = data;
alert(111);
}).error(function(error){
$scope.error = error;
alert(222);
})
}
})
</script>
</body>
</html>
解决方案
已经找到解决办法了哟,前端代码没问题,只要改一下后台就好了
这篇关于javascript - AngularJs使用Post为什么后台读不到数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文