axios jquery ajax

axios @RequestBody

post

javascript 复制代码
axios.post('/vue/insert', this.newStudent)
                    .then(r => {
                    console.log('Student added successfully:', r);
                }).catch(e => {   console.error('There was an error adding the student!', e);     });

后端

java 复制代码
@RestController
@RequestMapping("/vue")
public class VueController {
    @PostMapping("/insert")
    String test(@RequestBody Map map){
        System.out.println(map);
        return "OK";
    }

}

jquery post JSON.stringify @RequestBody

ajax

javascript 复制代码
 $.ajax({
                      type:'post',
                      url:"vue/insert",
                      data: JSON.stringify(this.newStudent),
                      contentType:"application/json",
                  }).then(r=>{console.log(r)})

post

javascript 复制代码
 $.ajaxSetup({
                    headers: {
                        'Content-Type': 'application/json'
                    }
                });
                $.post('/vue/insert',JSON.stringify( this.newStudent)).then(r=>{
                        console.log("then:"+r)
                    }).fail(e=>{console.log("fail"+e)})

后端

java 复制代码
@RestController
@RequestMapping("/vue")
public class VueController {
    @PostMapping("/insert")
    String test(@RequestBody Map map){
        System.out.println(map);
        return "OK";
    }

}

jquery post @RequestParam

post

javascript 复制代码
 $.post('/vue/insert',this.newStudent).then(r=>{
                        console.log("post  then:"+r)
                    }).fail((a,b,c)=>{console.log(a)})

ajax

javascript 复制代码
$.ajax({
                      type:'post',
                      url:"vue/insert",
                      data: this.newStudent
                  }).then(r=>{console.log("ajaxthen:"+r)})

jquery get @RequestParam

get

javascript 复制代码
$.get('/vue/insert',this.newStudent).then(r=>{
                        console.log("get  then:"+r)
                    }).fail((a,b,c)=>{console.log(a)})
相关推荐
自在极意功。14 小时前
AJAX 深度详解:从基础原理到项目实战
前端·ajax·okhttp
William_cl19 小时前
【ASP.NET Core】Controller 层 Action 返回值精讲:JsonResult(AJAX 交互核心)
ajax·asp.net·交互
北极糊的狐2 天前
关于jQuery 事件绑定,记录常用事件类型及核心注意事项
前端·javascript·jquery
APIshop3 天前
代码解析:通过第三方爬虫获取1688商品详情接口
爬虫·okhttp
San303 天前
深入理解 JavaScript 异步编程:从 Ajax 到 Promise
javascript·ajax·promise
青衫码上行4 天前
【Java Web学习 | 第15篇】jQuery(万字长文警告)
java·开发语言·前端·学习·jquery
合作小小程序员小小店5 天前
web网页开发,在线%食堂管理%系统,基于Idea,html,css,jQuery,java,ssm,mysql。
java·前端·mysql·html·intellij-idea·jquery
会编程的李较瘦6 天前
【Spark学习】数据清洗
学习·ajax·spark
Entropless6 天前
OkHttp 深度解析(一) : 从一次完整请求看 OkHttp 整体架构
android·okhttp
曹绍华6 天前
okhttp建造者模式详解
okhttp·建造者模式