sheriffderek
sheriffderek

Reputation: 9043

Dynamicly inject content with ajax / but with php instead of html

Been building sites with this code from chris coyier recently. Ajax jquery .load() etc.

everything is working great.

see code dump here http://css-tricks.com/dynamic-page-replacing-content/

$(function() {

var newHash      = "",
    $mainContent = $("#main-content"),
    $pageWrap    = $("#page-wrap"),
    baseHeight   = 0,
    $el;

$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();

$("nav").delegate("a", "click", function() {
    window.location.hash = $(this).attr("href");
    return false;
});

$(window).bind('hashchange', function(){

    newHash = window.location.hash.substring(1);

    if (newHash) {
        $mainContent
            .find("#guts")
            .fadeOut(200, function() {
                $mainContent.hide().load(newHash + " #guts", function() {
                    $mainContent.fadeIn(200, function() {
                        $pageWrap.animate({
                            height: baseHeight + $mainContent.height() + "px"
                        });
                    });
                    $("nav a").removeClass("current");
                    $("nav a[href='"+newHash+"']").addClass("current");
                });
            });
    };

});

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

});

HOWEVER - I have now been turning all my pages into php - and I can't seem to hack it together... I thought I could just change the "html" to "php" in the jQuery... but that is not working...

Any help ?

Upvotes: 0

Views: 120

Answers (1)

sheriffderek
sheriffderek

Reputation: 9043

Sorry to waste your time guys - I had been in front of this computer an unhealthy amount of time.

I had rushed and replaced href with php ... (thinking it was html)

REMEMBER TO TAKE BREAKS EVERYONE - OR FACE LOOKING LIKE A FOOL (Like me)

-thanks for your time...

Upvotes: 1

Related Questions