开发者

cakephp ajax not working

开发者 https://www.devze.com 2023-04-02 22:00 出处:网络
I\'ve 2 ajax form in my ctp, One is working and other is not,instead it gets redirected. This is my .ctp file

I've 2 ajax form in my ctp, One is working and other is not,instead it gets redirected.

This is my .ctp file

<div>
            <?php  echo $ajax->form('deletecreativeschedule','post',array('id'=>'delete','model'=>'admin','update'=>'myTable')); ?>                
            <input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />
             <input type="hidden" name="scheduleid" id="scheduleid"/>
             <input name="btnDelete" type="image" src="/<?php echo $site_root ?>/img/btnDelete.gif" height="16" class="sbtnDelete"  id="sbtnDelete" onclick="return deleteSchedule();"  title="Delete creative" >
            <?php echo $form->end(); ?>

            <br>
            <?php  echo $ajax->form('swapcreativeschedule','post',array('id'=>'swap','controller'=>'admin','update'=>'myTable')); ?>                
            <input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />                 
             <input type="hidden" name="aIdAjax" id="aIdAjax"/>
             <input type="hidden" name="aSeqAjax" id="aSeqAjax"/>


           <input name="btnUP" type="image" src="/<?php echo $site_root ?>/img/up.png" class="sbtnup"  id="sbtnup" onclick="return SwapRow('0');"  title="Delete creative" >
            <input name="btnDown" type="image" src="/<?php echo $site_root ?>/img/down.png" class="sbtndown"  id="sbtnup" onclick="return SwapRow('1');"  title="Delete creative" >
            <?php echo $form->end(); ?>

and in controller:

function deletecreativeschedule()
{
$this->autorender = false;
    $this->layout = 'ajax';
}
function swapcreativeschedule()
{
$this->autorender = false;
    $this->layout = 'ajax';
}

and in views/admin开发者_JAVA技巧 folder i've created files deletecreativeschedule.ctp and swapcreativeschedule.ctp

ajax is working fine for deleteschedule but for swapcreativeschedule it is redirecting to /admin/swapcreativeschedule

what is wrong here?


I hope it'll work,

  <?php  echo $form->create('deletecreativeschedule'); ?>                
        <input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />
         <input type="hidden" name="scheduleid" id="scheduleid"/>
         <input name="btnDelete" type="image" src="/<?php echo $site_root ?>/img/btnDelete.gif" height="16" class="sbtnDelete"  id="sbtnDelete" onclick="return deleteSchedule();"  title="Delete creative" >
         <? echo $ajax->submit('btnDelete.gif',array("url"=>array('controller'=>'your controller','action'=>'ur action',$device['Device']['id']),'class'=>'sbtnDelete','update'=>'ur updateDiv') ?>
<?php echo $form->end(); ?>


<br>
 <?php  echo $form->create('swapcreativeschedule'); ?>                
        <input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />                 
         <input type="hidden" name="aIdAjax" id="aIdAjax"/>
         <input type="hidden" name="aSeqAjax" id="aSeqAjax"/>

<? echo $ajax->submit('up.png',array("url"=>array('controller'=>'your controller','action'=>'ur action',$device['Device']['id']),'class'=>'sbtnup','update'=>'ur updateDiv') ?>
<? echo $ajax->submit('down.png',array("url"=>array('controller'=>'your controller','action'=>'ur action',$device['Device']['id']),'class'=>'sbtndown','update'=>'ur updateDiv') ?>

 <?php echo $form->end(); ?>
0

精彩评论

暂无评论...
验证码 换一张
取 消