頁面取參數 先寫一個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傳的數值