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)})
相关推荐
maycho1231 天前
裂隙瓦斯模型的Comsol模拟之旅
okhttp
spencer_tseng2 天前
jquery.min.js v1.12.4
javascript·jquery
码界奇点2 天前
Java Web学习 第15篇jQuery万字长文详解从入门到实战解锁前端交互新境界
java·前端·学习·jquery
A24207349302 天前
使用jQuery动态操作HTML和CSS
css·html·jquery
spencer_tseng3 天前
jquery download
javascript·jquery
weixin_307779135 天前
Jenkins jQuery3 API 插件详解:赋能插件前端开发的利器
运维·开发语言·前端·jenkins·jquery
他是龙5517 天前
第31天:WebPack 与 jQuery 安全
安全·webpack·jquery
渴望成为python大神的前端小菜鸟8 天前
浏览器及其他 面试题
前端·javascript·ajax·面试题·浏览器
chilavert3188 天前
技术演进中的开发沉思-235 Ajax:动态数据(上)
javascript·ajax·okhttp
灰什么鱼9 天前
OkHttp + Retrofit2 调用第三方接口完整教程(以nomad为例)
java·spring boot·okhttp·retrofit