Remove the hash after Ajax loading (I'm ajaxing wordpress 8-) )

Posted by Alberto on Stack Overflow See other posts from Stack Overflow or by Alberto
Published on 2010-06-09T18:22:43Z Indexed on 2010/06/10 7:42 UTC
Read the original article Hit count: 138

Filed under:
|
|
|

Hi everybody, I followed this great tutorial to"ajax" my blog:http://www.deluxeblogtips.com/2010/05/how-to-ajaxify-wordpress-theme.html But it creates some problems and I think the problem is in the hash that ajax creates. So, after the content is loaded, how can I remove the hash from the url? I copy my code here:

    jQuery(document).ready(function($) { 
    var $mainContent = $("#content"), 
        siteUrl = "http://" + top.location.host.toString(), 
        url = ''; 

    $(document).delegate("a[href^='"+siteUrl+"']:not([href*=/wp-admin/]):not([href*=/wp-login.php]):not([href$=/feed/]):not([href*=/go.php]):not(.comment-reply-link)", "click", function() { 
        location.hash = this.pathname;
$('html, body').animate({scrollTop:0}, 'fast');
        return false; 
    }); 

    $("#searchform").submit(function(e) { 
        location.hash = '?s=' + $("#search").val(); 
        e.preventDefault(); 
    }); 

    $(window).bind('hashchange', function(){ 
        url = window.location.hash.substring(1); 

        if (!url) { 
            return; 
        } 

        url = url + " #inside"; 

        $mainContent.html('<div id="loader">Caricamento in corso...</div>').load(url, function() { 
            //$mainContent.animate({opacity: "1"});
            scriptss();
        }); 
    });

    $(window).trigger('hashchange'); 
});

Thank all very much!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX