jquery - how to change the onhashchange value click on browserback button in wordpress ajax -


i trying fetch wordpress ajax posts browswerback button, means when user click on browser backbutton post loaded click on title of post show, want show previous post using browser backbutton, have used code, working fine when user click on post not working browser button, stuck problem. can tell me solution of problem.

    success: function(response) {     jquery("#loading-animation").addclass('loadingstyle');     jquery("#loading-animation").text(function(){     if(location.hash){     // got hash value! lets take off hash , smoke it.     var newhash = window.location.hash.substring(1);     jquery("#loading-animation").html(response);     // uncomment above code see if 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. 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 show");     }     }            });      return false;     } 

you using e.preventdefault(); causes stop further events (clicks).

so remove e.preventdefault(); following code

$(".ajaxclick").click(function(e){       e.preventdefault();      window.location.hash = $(this).attr("href"); }); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -