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)})
相关推荐
stella·3 小时前
后端二进制文件,现代前端如何下载
前端·ajax·状态模式·axios·request·buffer·download
胖虎14 小时前
Android 文件下载实践:基于 OkHttp 的完整实现与思考
android·okhttp·下载文件·安卓下载·安卓中的下载
极客先躯1 天前
基于 EasyUI 和 jQuery 封装的企业级日期时间选择器组件库,采用标准的 jQuery 插件开发规范,实现了高度模块化和可复用的 UI 组件
ui·jquery·日期选择器·时间选择器·easyui
深蓝电商API1 天前
Scrapy爬取Ajax动态加载页面三种实用方法
爬虫·python·scrapy·ajax
Aevget2 天前
Kendo UI for jQuery 2025 Q4新版亮点 - AI 助手持续加持,主力开发更智能
人工智能·ui·jquery·界面控件·kendo ui
满栀5852 天前
三级联动下拉框
开发语言·前端·jquery
假装我不帅2 天前
jquery-validation使用
前端·javascript·jquery
假装我不帅2 天前
rider开发asp.net webform项目
android·okhttp·asp.net
weixin_515069662 天前
OkHttp-HTTP 客户端框架
网络协议·http·okhttp·框架
木头程序员3 天前
前端(包含HTML/JavaScript/DOM/BOM/jQuery)基础-暴力复习篇
开发语言·前端·javascript·ecmascript·es6·jquery·html5