首页 > Web开发 > 详细

获取html 中的内容 将前台的数据获取到后台

时间:2016-12-29 22:58:07      阅读:278      评论:0      收藏:0      [点我收藏+]

使用js创建一个form表单 ,使用post上传到后台中 下面是代码。在获取html内容的时候使用了js节点来获取内容。

parent:父节点。上一级的节点

siblings:兄弟节点。同一级别的节点

技术分享

 

  $(function(){
                $(‘input[name=but]‘).click(function(){
                    var start=$(this).parent(‘div‘).siblings(‘div[name=qishi]‘).html();
                    var end=$(this).parent(‘div‘).siblings(‘div[name=mudi]‘).html();
                   var weight=$(this).parent(‘div‘).siblings(‘div[name=weight]‘).html();
                   var departid=$(this).parent(‘div‘).siblings(‘input[name=depart]‘).val();
                  //  alert($(this).parent(‘div‘).siblings(‘div[name=qishi]‘)..html());
                    //调用
                    post(‘matching‘, {‘start‘:start,‘end‘:end,‘weight‘:weight,‘departid‘:departid});
                });
            });
            function post(URL, PARAMS) {
                var temp = document.createElement("form");
                temp.action = URL;
                temp.method = "post";
                temp.style.display = "none";
                for (var x in PARAMS) {
                    var opt = document.createElement("textarea");
                    opt.name = x;
                    opt.value = PARAMS[x];
                    // alert(opt.name)
                    temp.appendChild(opt);
                }
                document.body.appendChild(temp);
                temp.submit();
                return temp;
            }
           

 

获取html 中的内容 将前台的数据获取到后台

原文:http://www.cnblogs.com/wjm956/p/6234791.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!