用户按回按钮时是否记得更新的ajax html?

时间:2015-10-09 01:13:50

标签: javascript jquery ajax

我正在尝试让浏览器记住ajax更新的html。因此,当用户点击后退按钮时,它将返回到ajax update html。我从stackoverflow找到了以下代码,但我不知道如何使用它。我曾尝试用我的类.post-content替换#Mytable。但它不起作用,我会错过什么。帮助,欣赏。



$('#pagination').click(function(e){
	
	var data = {
		            action: 'post_pagination_ajax',
				    AjaxFrontNonce : Child_ajax.ajaxLoadUserNonce,
				
				};
	$.ajax({
		url: ajax_front_gallery.ajaxurl,
		type:'POST',
		data: data,
		success: function(data){
		$('.post-content').fadeOut().html(data).fadeIn();
				$fa_spen.fadeOut();
		}
		});
		  return false;		
});

	

// the following code found on stackoverflow, but I don't know how to replace it with my code.
	if (('localStorage' in window) && window['localStorage'] !== null) {
	    if ('myTable' in localStorage && window.location.hash) {
	        $("#myTable").html(localStorage.getItem('myTable'));
	    }
	}/*remember the previous div position*/

	// Replace the search result table on load.
	if (('localStorage' in window) && window['localStorage'] !== null) {
	    if ('myTable' in localStorage && window.location.hash) {
	        $("#myTable").html(localStorage.getItem('myTable'));
	    }
	}




0 个答案:

没有答案