Flask框架--前端获取参数传给后台

 log:

需求及解决的问题:

1.前端表格展示后端接口给的参数

2.input文本框输入参数

3.需要把这些参数二次传给后端接口处理

4.类型不同,前端获取参数的方法不同

            var mobile_key= document.getElementById('mobile_key').innerHTML;  //获取表格数据
            var customer_id=document.getElementById('customer_id').innerHTML;
            var mobile = document.getElementById('mobile').value;  //获取input文本框数据

 {% for i in mobilkey %}
            <tr id="mobile12">
                <td class="text-center .a1" id="a1">{{i.plat_code}}</td>
                <td class="text-center .a2">{{i.third_caption}}</td>
                <td class="text-center .a3">{{i.shop_id}}</td>
                <td class="text-center .a4" id="mobile_key">{{i.mobile_key}}</td>
                <td class="text-center .a5" id="customer_id">{{i.customer_id}}</td>
                <td class="text-center .a6">{{i.tenant_id}}</td>
                <td class="text-center"><input type="text"  name="mobile" id="mobile" title="输入需要加密的手机号"></td>
                <td class="text-center">
                <div class="layui-btn phone" lay-submit lay-filter="*">加密</div>
<!--                    <button onclick="window.location.href='/lp3/md5_mobilekey?mobile_key={{ i.mobile_key }}&customer_id={{i.customer_id}}&tenant_id={{i.tenant_id}}&mobile='+document.getElementById('mobile').value ;if(confirm('加密确认')== false) return false;" style="color: #dc143c" class="" >加密</button>-->
                </td>
            </tr>
            {% endfor %}

 

<script type="text/javascript">
//搜索结果局部刷新
$(function() {
        $('.phone').click(function () {
            var mobile_key= document.getElementById('mobile_key').innerHTML;
            var customer_id=document.getElementById('customer_id').innerHTML;
            var mobile = document.getElementById('mobile').value;

            $.ajax({
                type: 'GET',
                url: '/lp3/md5_mobilekey',
                data: {"mobile_key":mobile_key,"customer_id":customer_id,"mobile":mobile},
                success: function (data) {  // 这个data是接收到的响应的实体
                    $('.result').val(data["mobile"]);

                }
            });
        });
    })
        </script>

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值