browswerback ボタンを使用してワードプレスの ajax 投稿を取得しようとしています。つまり、ユーザーがブラウザーの戻るボタンをクリックすると、投稿のタイトルをクリックして以前に読み込まれた投稿が表示されます。このために、ブラウザーの戻るボタンを使用して前の投稿を表示したいです。私はこのコードを使用しました。ユーザーが投稿をクリックすると正常に動作しますが、ブラウザの戻るボタンでは動作しません。この問題で立ち往生しています。誰でもこの問題の解決策を教えてください。
success: function(response) {
jQuery("#loading-animation").addClass('loadingstyle');
jQuery("#loading-animation").text(function(){
if(location.hash){
// We got a hash value! Lets take off the hash and smoke it.
var newhash = window.location.hash.substring(1);
jQuery("#loading-animation").html(response);
// uncomment the above code to see if it works.
}else{
alert("No hash available.");
// no hash value
}
$(".ajaxclick").click(function(e){
e.preventDefault();
window.location.hash = $(this).attr("href");
});
// $(window).on('hashchange', function() {
window.onhashchange = function(){
// hash changed. Do something cool.
if(location.hash){
var hash = window.location.hash.substring(1);
// console.log(response);
jQuery("#loading-animation").html(response);
}else{
// load home page
// jQuery("#loading-animation").html(response);
alert("No more content to show");
}
}
});
return false;
}