【网页-JQuery】通过Js获取表单提交的数据。

https://zhidao.baidu.com/question/550893193.html



<html>
<body>
    <form method='post' action=''>
        <label for='inputText'>inputText</label>
        <input type='text' id='inputText'/>
         
        <label for='checkBox1'>checkBox1</label>
        <input type='checkbox' id='checkBox1'/>
         
        <label for='checkBox2'>checkBox2</label>
        <input type='checkbox' id='checkBox2'/>
        <!--其他你想填写的表单选项-->
        <input type='button' value='提交表单' id='submitBtn'/>
    </form>
    <script>
        $(document).ready(function()
        {
            $('#submitBtn').click(function(e)
            {
                /*一系列根据自己的意图判断输入框是否已输入内容并决定是否往下执行*/
                 
                //获取表单的系列化数据。这会生成一个A=valueA&B=valueB这种形式的字符串。
                var formData = $('form').serialize();
                $.post('目标地址',formData,成功/失败回调函数);
                e.preventDefault();
            });
             
        });
    </script>
</body>
</html>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值