在ajax调用</div>期间重新加载页面的特定<div>

时间:2011-11-10 05:29:23

标签: php javascript jquery cakephp-1.3

我遇到了以下问题。问题是,我想重新加载我的页面的特定div,它也包含PHP脚本。我的javaScript函数是

function select_dayoff() {
    jQuery('#loader').css('display','block');
    var site = "<?php echo SITE_NAME.ROOT_FOLDER_NAME ?>"+"fschedules/dayoff";
    jQuery.ajax({
           type: "POST",
           url: site,
           data: "&fulldate="+MyDayoff.dayof,
           success: function(msg){
               jQuery('#loader').css('display','none');
           }
    });
}

和DIV是:

<span id="fill_available_time">
                    <?php $form->create(MEMBER_DAYOFF,array('id'=>'saveCancelDay','name'=>'saveCancelDay', 'type' => 'post', 'url'=>'/fschedules/dayoff')); ?>
                    <div class="profile">
                        <?php
                            if(!empty($dayoff_time)){

                                foreach($dayoff_time as $key => $val){
                                    $res_dayoff_time[$val[MEMBER_DAYOFF]['dayoff']] = $val[MEMBER_DAYOFF]['dayoff'];
                                }
                                //echo $form->input('id_state',array('label'=>'','type'=>'select','id'=>'state_id', 'options'=>@$res_business_state, 'empty'=>'Please select...' ,'class'=>'required'));
                                //echo '<h2>Select date for cancel dayoff</h2>';
                                echo $form->input('dayoff_time', array('label'=>'','type'=>'select','id'=>'dayoff_time', 'options'=>$res_dayoff_time, 'empty'=>'Please select...' ,'class'=>'required' ,'onchange'=>'','style'=>'margin-left: 14px;'));
                                echo $form->submit('Cancel Dayoff', array('type'=>'submit','name'=>'saveCancelDay','id'=>'saveCancelDay')); 
                            }else{
                                echo '<h2>No Dayoff is registered.</h2>';
                            }

                        ?>
                    </div>
                    <?php $form->end(null); ?>
                </span>

我想在上面的Ajax调用期间刷新这个DIV。 提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

创建一个html文件xyz.html并添加html代码

   <?php $form->create(MEMBER_DAYOFF,array('id'=>'saveCancelDay','name'=>'saveCancelDay', 'type' => 'post', 'url'=>'/fschedules/dayoff')); ?>
<div class="profile"><?php 
    if(!empty($dayoff_time)){ 

    foreach($dayoff_time as $key => $val){ 
    $res_dayoff_time[$val[MEMBER_DAYOFF]['dayoff']] = $val[MEMBER_DAYOFF]['dayoff']; 
    } 
    //echo $form->input('id_state',array('label'=>'','type'=>'select','id'=>'state_id', 'options'=>@$res_business_state, 'empty'=>'Please select...' ,'class'=>'required')); 
    //echo '<h2>Select date for cancel dayoff</h2>'; 
    echo $form->input('dayoff_time', array('label'=>'','type'=>'select','id'=>'dayoff_time', 'options'=>$res_dayoff_time, 'empty'=>'Please select...' ,'class'=>'required' ,'onchange'=>'','style'=>'margin-left: 14px;')); 
    echo $form->submit('Cancel Dayoff', array('type'=>'submit','name'=>'saveCancelDay','id'=>'saveCancelDay')); 
    }else{ 
    echo '<h2>No Dayoff is registered.</h2>'; 
    } 

    ?></div>
<?php $form->end(null); ?>






function select_dayoff() {
        jQuery('#loader').css('display', 'block');
        var site = "<?php echo SITE_NAME.ROOT_FOLDER_NAME ?>"
                + "fschedules/dayoff";
        jQuery.ajax( {
            type :"POST",
            url :site,
            data :"&fulldate=" + MyDayoff.dayof,
            success : function(msg) {
                jQuery('#loader').css('display', 'none');
                $('#fill_available_time').load('xyz.html')
            }
        });
    }