Transmitting and receiving parameters between the parameter and the html page to achieve html

Transmitting and receiving parameters between the parameter and the html page html

To achieve the parameter passing between html and html pages, only need to add the following js code in html page

 <script type="text/javascript">
        <!--获取页面之间的传递的参数-->
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = decodeURI(window.location.search).substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }

        function update() {
            var id = getQueryString("id");
            alert("上一个页面传递的值:"+id);
            var val = $("#form-brand-modify").serialize();
            $.post("../update","id="+id+"&"+$("#form-brand-modify").serialize(),function(obj) {
                    window.location.href="../main";
            },"json");
        }

</script>

Guess you like

Origin www.cnblogs.com/jasonboren/p/12286010.html