jquery批量获取form表单要提交的值

jquery代码:

alert($("form").serialize());
    
    
  • 1

完整请求:
这个方法适用于get请求,对于post请求我没试过。

   $("#generate").click(function(){
    $.ajax({
           url:"organization/generateAuthCode", //你的路由地址
           type:"post",
           dataType:"json",
           data:$("form").serialize(),,
           timeout:30000,
           success:function(data){
             $("#description").value(data);
           },
           error:function(){
            console.log(data);
          }
        });
  });
    
    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

我在后端返回接收到的数据:

这里写图片描述

get也是可以的:

这里写图片描述

        <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/markdown_views-ea0013b516.css">
            </div>

jquery代码:

alert($("form").serialize());
  
  
  • 1

完整请求:
这个方法适用于get请求,对于post请求我没试过。

   $("#generate").click(function(){
    $.ajax({
           url:"organization/generateAuthCode", //你的路由地址
           type:"post",
           dataType:"json",
           data:$("form").serialize(),,
           timeout:30000,
           success:function(data){
             $("#description").value(data);
           },
           error:function(){
            console.log(data);
          }
        });
  });
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

我在后端返回接收到的数据:

这里写图片描述

get也是可以的:

这里写图片描述

        <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/markdown_views-ea0013b516.css">
            </div>

猜你喜欢

转载自blog.csdn.net/qyl_0316/article/details/81007546
今日推荐