分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

angular 发送ajax

发布时间:2023-09-06 02:05责任编辑:蔡小小关键词:暂无标签

  在使用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.show12 ???????????????????????}13 ???????????????}).then(function successCallback (rs){14 ???????????????????$scope.show = rs.data;15 ???????????????}); ??16 ???????????}17 ???????});18 ????</script>

  后台接收:

1 ????@RequestMapping(value="/verfiy", method=RequestMethod.GET)2 ????@ResponseBody3 ????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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved