使用 ajax / 但使用 php 而不是 html 动态注入内容


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

最近一直在用Chris Coyier的这段代码构建网站。 Ajax jquery .load() etc.

一切都很好。

请参阅此处的代码转储 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');
});

但是 - 我现在一直在将我所有的页面都变成 php - 我似乎无法一起破解它......我想我可以在jQuery中将"html"更改为"php"... 但这行不通...

有什么帮助吗?

很抱歉浪费了你们的时间,伙计们 - 我一直在这台电脑前呆了不健康的时间。

我急于用 php 替换了 href ......(以为是html)

记得休息一下每个人 - 或者看起来像个傻瓜(像我一样)

-感谢您的时间...