问题
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');
});
The if is checking that everything went ok with the previous setup phase.
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;
}
} ?>
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. 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.
回答1:
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');
回答2:
You missed DIV ID in the end of your .load
$('#setup_form').load('./includes/db_setup_form.php #setup_form');
来源:https://stackoverflow.com/questions/8021481/refreshing-a-div-without-refreshing-the-page