刷新div而不刷新页面 [英] refreshing a div without refreshing the page

查看:135
本文介绍了刷新div而不刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行设置过程以设置数据库. 我试图让用户不刷新页面就经历所有阶段. 我被困在我想使用.load()jQuery函数的地方. 这是javascript:

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. This is the javascript:

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

if正在检查上一步设置是否一切正常.

The if is checking that everything went ok with the previous setup phase.

db_setup_form.php的工作方式如下:

db_setup_form.php works like this:

<?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;

 }
} ?>

这是主页:

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

在用户完成第一个设置阶段后,将给出$ _SESSION ['setup_progress']变量. 问题是,如果在第一个安装阶段完成后手动刷新页面但javascript似乎不起作用,则div会显示,而没有更新的信息.

The $_SESSION['setup_progress'] variable is given after the user completes the first setup phase. 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.

谢谢 据我所知一切应该没事...但事实并非如此.

thanks From what i know everything should be ok...but it is not.

推荐答案

您应提供有效的url而不是路径.所以:

you should provide a valid url instead of a path. So:

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

应该是

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

这篇关于刷新div而不刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆