0
点赞
收藏
分享

微信扫一扫

2023年9月12日

2023年9月12日_jquery

描述:通过前台html页面,发送请求,获取后台的数据

html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<button id="get">登录测试</button>
<script>
    $(function () {
        $("#get").on('click',function () {
            $.get('http://localhost:8082/test/h1',function (res) {
                alert(res);
            })
        })
    })
</script>
</body>
</html>

Java

@RestController
@RequestMapping("/test")
public class HelloController {

    @GetMapping("/h1")
    public String h1(){
        return "登录成功";
    }
}

涉及到的

使用到的有HTML、jQuery、Java、JavaScript、ajax

通过点击按钮,向后台发送请求,获取到数据,并展示到页面

一起交流,一起学习,向前,向前,向前!!!

举报

相关推荐

0 条评论