简体   繁体   English

刷新div而不刷新页面

[英]refreshing a div without refreshing the page

i'm making a setup process to setup a db. 我正在设置数据库的设置过程。 I'm trying to let the user go through all the phases without refreshing the page. 我正在尝试让用户无需刷新页面即可完成所有阶段。 I'm stuck at a point where i want to use the .load() jquery function. 我被困在我想使用.load()jquery函数的地方。 This is the javascript: 这是javascript:

if(response.error == 'none')
  $("#setup_form").slideToggle('fast', function() {
  $('#setup_form').load('./includes/db_setup_form.php');
  $("#setup_form").delay(1000).slideToggle('fast');
});

The if is checking that everything went ok with the previous setup phase. if正在检查在上一个设置阶段中一切正常。

db_setup_form.php works like this: db_setup_form.php的工作方式如下:

<?php if ($_SESSION['setup_progress'] == NULL) {?>
Starting phase
<?php } 
else {
 switch ($_SESSION['setup_progress'])
 {
    case "1":?>
    phase 1
    <?php break;

    case "2":?>
        phase 2
    <?php break;

 }
} ?>

and this is the main page: 这是主页:

<div id="setup_form">
  <?php include('./includes/db_setup_form.php'); ?>
</div>

The $_SESSION['setup_progress'] variable is given after the user completes the first setup phase. 用户完成第一个设置阶段后,将给出$ _SESSION ['setup_progress']变量。 The problem is that everything works if i manually refresh the page once the first installation phase is done but the javascript does not seem to work, the div gets displayed without the updated informations. 问题是,如果在第一个安装阶段完成后手动刷新页面但javascript似乎不起作用,则div会显示,而没有更新的信息,一切都会正常。

thanks From what i know everything should be ok...but it is not. 谢谢据我所知一切应该没事...但事实并非如此。

您在.load末尾错过了DIV ID

$('#setup_form').load('./includes/db_setup_form.php #setup_form');

you should provide a valid url instead of a path. 您应该提供有效的网址而不是路径。 So: 所以:

.load('./includes/db_setup_form.php');

should be 应该

.load('/includes/db_setup_form.php');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM