我有一个表格,从后端以json,
的形式提取的值在其中一个单元格中,我有一个按钮,点击此按钮我想渲染另一个xhtml页面,但我也想要一个参数与超链接一起传递如何实现这一点,在此先感谢我发布我的代码供参考,
$.get('../Paid_deep_dive', {type: "paid_performance", campaign_id: $campaign, s_date: start_date, e_date: end_date}, function (response) {
var data = response.paid_performance;
response_data = response;
$('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="loadtable2(' + elem.site_id + ')" value="' + elem.site_name + '" style="width:100%" ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');
});
在上面的代码中,我希望在
上有一个超链接onclick = "http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=" + parameter;
以及传递参数。有没有办法正确地做到
答案 0 :(得分:2)
通过分配到window.location.href
:
$('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="window.location.href=\'http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=' + encodeURIComponent(parameter) + '\'" value="' + elem.site_name + '" style="width:100%" ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');