0
点赞
收藏
分享

微信扫一扫

使用ajax设置html中input中的值

ITWYY 2022-04-13 阅读 60
html

标题:使用ajax设置html中input中的值

参考blog:添加链接描述

使用: $("#username").val("我设置的值")设置值
在这里插入图片描述

 $(function () {
            var username = getParameter("username");
            var email = getParameter("email");
            var comId = getParameter("comId");
            // alert(username + " " + email + " " + comId + " ");

            //调用 显示数据+分页
            // my_load_data(1);
            my_load_data(1,username,email,comId);


        })
        
        //搜索  点击提交触发
        function my_search() {
            var username = $("#username").val();
            var email = $("#email").val();
            var comId = $("#comId").val();
            //添加搜索内容
            $.ajax({
                method: "post",
                url: "http://localhost:8080/user/list",
                data:{"username":username,"email":email,"comId":comId},
                success:function () {
                    location.href="http://localhost:8080/backPage/userDesign.html?username="+username+"&email="+email+"&comId="+comId+"";
                }
            })


        }

        //加载数据
        function my_load_data(current,username,email,comId) {
            $.get("../user/list",{current,username,email,comId},function (data) {
                $("#username").val(username)
                $("#email").val(email);
                $("#comId").val(comId);
举报

相关推荐

0 条评论