zoukankan      html  css  js  c++  java
  • 前台向后台传值的两种方法 以及 从后台获取数据的方法

    1、前台向后台传值方法一:

    表单提交的方式:

     1 <form action="${path }/manage/logon.do" method="post" id="logonForm">
     2   <table cellpadding="0" cellspacing="0" border="0">
     3     <tr height="50">
     4       <td>
     5         <input type="text"  id="userIdMark" name="userIdMark" />
     6         <input type="hidden"  id="userId" name="userId" />
     7       </td>
     8     </tr>
    15     <tr height="60">
    16       <td>
    17         <a href="#" id="logon" name="submit" class="login_btn"></a>
    18       </td>
    19     </tr>
    20   </table>
    21 </form>

    js代码:

    1 $("#logon").click(function(){
    2     $("#logonForm").submit();
    3 });

    2、前台向后台传值方法二ajax:

    1  <form id="myform" method="post" action="http://images.byshop.com/wechat/imgFormUpload" enctype="multipart/form-data">
    2       <input type="file" name="userfile[]"  multiple id="img_file">
    3       <input type="submit" value="shangchuan">
    4   </form>
    5   <input type="button" value="ajax_submit" onclick="imgFormUpload()">

    js代码:

      function imgFormUpload() {
             $.ajax({
                  dataType: 'json',
    url:
    http://images.byshop.com/wechat/imgFormUpload,
    success: function (data) {
    alert("submit success");
    }
    });
    }

    通过ajax从后台取值的方法,从后台获得值显示在列表中,如下图:

     1 <script type="text/javascript">
     2         $(function(){
     3            var Request = new Object();
     4             Request = GetRequest();
     5             var url;
     6             url = Request['vbillcode'];
     7              
     8             $.ajax({
     9                         type : 'POST',
    10                         url : "/rm/rmcsale/edit_specapplydetail",
    11                         data : {Listurl : url},
    12                         async:false,
    13                         success : function(data) {
    14                             console.log("----------- success-------------");
    15                              alert("您查询的订单号为:"+data.vbillcode);
    16                                $(".J-vbillcode").attr("value",data.vbillcode);
    17                                $(".J-billmaker").attr("value",data.billmaker);
    18                                $(".J-ctrantypeid").attr("value",data.ctrantypeid);
    19     
    20                         },
    21                         error : function(data) {
    22                              
    23                         },
    24                         dataType : 'json',
    25                          
    26                     });
    27              
    28              
    29          
    30         });
    31         </script>

    备注:靠自己也可以!依赖别人或者老师没有出路!

  • 相关阅读:
    node.js 安装后怎么打开 node.js 命令框
    thinkPHP5 where多条件查询
    网站title中的图标
    第一次写博客
    Solution to copy paste not working in Remote Desktop
    The operation could not be completed. (Microsoft.Dynamics.BusinessConnectorNet)
    The package failed to load due to error 0xC0011008
    VS2013常用快捷键
    微软Dynamics AX的三层架构
    怎样在TFS(Team Foundation Server)中链接团队项目
  • 原文地址:https://www.cnblogs.com/xu-blog/p/7118756.html
Copyright © 2011-2022 走看看