首页 > Web开发 > 详细

angular 发送ajax

时间:2018-07-20 13:12:36      阅读:153      评论:0      收藏:0      [点我收藏+]

  在使用angular发送ajax的时候get和post一样的,就是method改一下。

       ajax的js:

 1      <script>
 2        var app = angular.module(‘emialVerfiy‘,[]);
 3        app.controller(‘ev‘,function($scope,$http){
 4            $scope.send = function(){
 5                
 6                $http({
 7                    method:‘get‘,
 8                    url:‘../mailVerfiy/verfiy‘, 
 9                    contentType:‘application/json;charset=UTF-8‘,
10                    params : {
11                        ‘mial‘ : $scope.show
12                        }
13                }).then(function successCallback (rs){
14                    $scope.show = rs.data;
15                });   
16            }
17        });
18     </script>

 

  后台接收:

1     @RequestMapping(value="/verfiy", method=RequestMethod.GET)
2     @ResponseBody
3     public String verfiy(@RequestParam(value="mial", required=true) String mail)
4     {
5         mailVerService.sendMail(mail);
6         return "发送成功,请去邮箱验证。";
7     }

 

  ps:

   要是遇到

     Status Code:400 Required String parameter ‘mail‘ is not present 

   这种错误的话,应该是参数传入的格式有问题,接受不到造成的。

 

angular 发送ajax

原文:https://www.cnblogs.com/goblinn/p/9340749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!