dongshao1156
2011-11-28 23:56
浏览 259
已采纳

如何成功重新加载包含的php页面?

I have a php page in which I want to include another php page, like this:

<?php
    include ("wrapper.php");
?>

It works just fine, but when I click on a div, which will trigger a javascript function like this:

function reloadNivoSlider () {
    $('#photo-show').fadeOut('slow', function () {
        $("#photo-show").load("nivo-slider/wrapper.php", function () {
            $('#photo-show').fadeIn('slow');
        })
    });
}

The div fades out and fades back in with the nivo slider loading forever. I tried to remove the animations, but the same happens. Could the MySQL request I do in wrapper.php be the reason of the problem? Does it stop the page from reloading? I actually don't know how $().load works, but I presume it reloads the page, right?

The wrapper.php file is:

<body>
<div id="wrapper">

    <div class="slider-wrapper theme-default">
        <div class="ribbon"></div>
        <div id="slider" class="nivoSlider">
            <?php
                mysql_connect(localhost,"root","");
                mysql_select_db("fotos") or die( "Unable to select database");

                $select = "SELECT * FROM 2a_mostra_kineret WHERE id='0';";
                $query = mysql_query($select);
                $row = mysql_fetch_assoc($query);

                $i = 0;

                while ($i <= 7) {
                    $verify = 1;
                    $random = rand(0,7);
                    // First Execution
                    if ($i == 0) {
                        $path[$i] = $row["path"] . $random . ".jpg";
                    }
                    // Other Executions
                    else {
                        while ($verify != 0) {
                            for ($s = 0; $s < $i; $s++) {
                                if ($row["path"] . $random . ".jpg" == $path[$s]) {
                                    $verify++;
                                    break;
                                }
                            }
                            if ($verify > 1) {
                                $random  = rand(0,7);
                                $verify = 1;
                            }
                            else $verify = 0;
                        }
                        $path[$i] = $row["path"] . $random . ".jpg";
                        //echo $random;
                    }
                    $i++;
                }

                for ($i = 0; $i <= 7; $i++) echo "<img src=\"$path[$i]\" alt=\"\" width=\"800\" height=\"600\"/>";

                mysql_close();
            ?>                              

        </div>
        <div id="htmlcaption" class="nivo-html-caption">
            <strong>This</strong> is an example of a <em>HTML</em> caption with <a href="#">a link</a>.
        </div>
    </div>

</div>
<script type="text/javascript" src="scripts/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="../jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider();
});
</script>

2条回答 默认 最新

相关推荐 更多相似问题