我有一个DIV
,.ASPX
当我点击它时,DIV
我会在我的 javascript 代码中触发它。
$("#btnFiltrar").click(function () {
var status = "";
var tipo = "";
var outros = "";
$("#divStatusImovel input").each(function () {
if ($(this).is(":checked") == true) {
var id = $(this).attr("id").replace("status_", "");
switch (id) {
case "1":
status += "at=t&";
break;
case "2":
status += "in=t&";
break;
case "14":
status += "ds=t&";
break;
case "3":
status += "vnd=t&";
break;
case "7":
status += "vndpr=t&";
break;
case "8":
status += "vndtr=t&";
break;
case "4":
status += "vndtr=t&";
break;
case "9":
status += "vndtr=t&";
break;
}
}
});
$("#divTipoImovel input").each(function () {
if ($(this).is(":checked") == true) {
var id = $(this).attr("id").replace("tipo_", "");
switch (id) {
case "1":
tipo += "t1=t&";
break;
case "2":
tipo += "t2=t&";
break;
case "3":
tipo += "t3=t&";
break;
case "4":
tipo += "t4=t&";
break;
case "5":
tipo += "t5=t&";
break;
case "7":
tipo += "t7=t&";
break;
case "8":
tipo += "t8=t&";
break;
case "9":
tipo += "t9=t&";
break;
case "14":
tipo += "t14=t&";
break;
case "15":
tipo += "t15=t&";
break;
case "17":
tipo += "t17=t&";
break;
case "145":
tipo += "t145=t&";
break;
}
}
});
$("#divOutrosTipos input").each(function () {
if ($(this).is(":checked") == true) {
var id = $(this).attr("id").replace("outros_", "");
switch (id) {
case "1":
outros += "ha=t&";
break;
case "2":
outros += "fa=t&";
break;
case "3":
outros += "fo=t&";
break;
case "4":
outros += "pl=t&";
break;
case "5":
outros += "dce=t&";
break;
}
}
});
var pathname = window.location;
pathname += "?" + status + tipo + outros;
pathname = pathname.substring(0, pathname.length - 1);
alert(pathname);
window.location = pathname;
});
在此 javascript 函数的最后一行中,我尝试将用户带到同一页面,但在我的 URL 上传递了一些参数但没有成功,在我的页面中重新加载但不传递我的 URL 上的参数。
谁能帮助我?
更新
好奇,当我在它debugger
之前放一个window.location.href
var pathname = window.location;
pathname += "?" + status + tipo + outros;
pathname = pathname.substring(0, pathname.length - 1);
debugger;
window.location.href = pathname;