Skip to main content

Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #30682
    spunkil
    Participant

    Hi,
    I’ve watched the #81: AJAXing a WordPress Theme tutorial on this site (https://css-tricks.com/video-screencasts/81-ajaxing-a-wordpress-theme/)
    And I tried implementing the code, with help of this one as well http://www.deluxeblogtips.com/2010/05/how-to-ajaxify-wordpress-theme.html

    I got the include right but when I activate it it doesn’t load anything into the content area when I press any link in my site, just stick at the homepage

    My file is:
    ajax.js:

    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/])", "click", function() {
    location.hash = this.pathname;
    return false;
    });

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

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

    if (!url) {
    return;
    }

    url = url + " #content";

    $mainContent.animate({opacity: "0.1"}).html('

    Please wait...').load(url, function() {
    $mainContent.animate({opacity: "1"});
    });
    });

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

    My site… : http://www.soniagarcia.co.il/?lang=en

    Any help would be appreciated

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.