我有2个页面,一个是图表页面,另一个是详细信息页面。在单击图表栏时,我得到了该值并将其传递给post方法,并从另一页获取响应。
图表页面:
$('.bar').click(function() {
$.ajax({
url: 'detail',
dataType: 'json',
data: filtervalues_rightclick,
type: 'post',
success: function(response) {
url_value = 'http://domain/detailview';
$url = url_value + response.query_string;
window.open($url, "_blank");
}
});
});
从详细信息视图获取值。我想将帖子回复零售在第二页(detail_view)中,即使在刷新页面时也是如此。因此,我已经在URL中传递了值。还有其他方法可以在URL中不传递参数吗?
答案 0 :(得分:0)
是的,您可以在AJAX请求中设置cookie,如下所示,并在其他页面上使用它:
$('.bar').click(function() {
$.ajax({
url: 'detail',
dataType: 'json',
data: filtervalues_rightclick,
type: 'post',
success: function(response) {
url_value = 'http://domain/detailview';
$url = url_value + response.query_string;
setCookie('pageurl', url, 1);
}
});
});
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}