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

如何成功重新加载包含的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条回答 默认 最新

  • dongqianzhan8325 2011-11-29 17:07
    关注

    No its not possible, ajax is the way. Check links http://api.jquery.com/jQuery.get/ http://api.jquery.com/category/ajax/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)