dsfbnhc4373 2013-11-12 02:46
浏览 32

尝试从不同的文件加载具有嵌套div的div

I need to have my index.php load some content from home.php. Within index.php, there is a div class="content" which contains a dialog box (for a user login). Within home.php, there is also a div class="content" which contains some p's and tables (tables are created dynamically with php by querying a database). When the user clicks submit on index.php, I would like to replace the the contents of div class="content" with the same div (including all tables, etc.) from home.php. The problem is when I load the new div, I lose all of the nested divs (including the php created rows and columns), which I need. Any help would be tremendously appreciated. Thanks in advance.

This is the html from index.php:

<div class="content" id="first">
        <div id="login">
            <p>Username:
                <input type="text" id="loginName" Required>
            </p>
            <p>Password:
                <input type="password" id="loginPass" Required>
            </p>
            <span id="loginError">Please enter a username AND password</span>

        </div>
</div><!--content=first-->

jquery from index.php:

$("#regButton").on('click',function(){
     $(".content").load("home.php .content >*");
});

html from home.php:

<div class="content" id="home">
    <div id="left">
        <div id="top">
        </div>
        <div id="bottom">
            <h2>Grades</h2>
        </div>
    </div>
    <div id="center">
        <h2>My Schedule</h2>
        <table>
                <tr>
                <td>Course ID</td>
                <td>Course Name</td>
            </tr>

            <?php
            echo "<tr>";
            echo "<td>" . $row['courseDept']. $row['courseNumber']. " - ". $row['courseSection']."</td>";
            echo "<td>" . $row['courseName']."</td>";
            echo "</tr>";               
            ?>
        </table>
    </div>
</div><!--content#home-->
  • 写回答

2条回答 默认 最新

  • dpy87530 2013-11-12 02:51
    关注

    One of the main issues I see is that having the same "ID" is not according to standard. Change one div from "content" to something else.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看