页面URL传参数及取参数


页面取参数  先写一个Js正则表达式

//获取Url参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)
        return unescape(r[2]);
    return null;
}

在用var取值

 var type = getUrlParam("Type");

传参:

"EtpList.ashx?action=GetQueryList"

传参会用在AJAX方法的URL里

 $.ajax(
            {
                type: "POST",
                url: "EtpList.ashx?action=GetQueryList",
                data: { page: page, count: count, type: type },
                contentType: "application/x-www-form-urlencoded",
                dataType: "json",
                async: false,
                cache: false,
                success: function (data)

后台EtpList.ashx页面的GetQueryList会接收到ajax传的数值


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM