zoukankan      html  css  js  c++  java
  • html 获取数据并发送给后端方式

    一、方式一

    使用ajax提交

           function detailed() {
                      var date = $("#asset_ip").text()
                      $.ajax({
                       url: "/assetslist",
                       type:'POST',
                       data: {"data":date},
                       }
    
                   })
               })
           }

    使用ajax提交后,后端只能返回HttpResponse。

    二、将数据封装在url里面提交

    //        通过绑定class点击事件,获取到当前行的id,通过url传送给后端。
            $(".detailed").click(function(){
                var dataId=$(this).attr('data_id');
                window.location.href = "/assetslist/?nid="+dataId;
            })

    使用url提交后端可以通过request.POST.get("nid")获取到id,从而可以通过id在数据库中查找相关数据。

  • 相关阅读:
    04.
    24
    39
    46
    72.
    21.
    logout: not found”
    Username is not in the sudoers file. This incident will be reported
    激活函数
    排序算法
  • 原文地址:https://www.cnblogs.com/liang-wei/p/9574543.html
Copyright © 2011-2022 走看看