Ajax + PHP Save data form

Ajax + PHP Save data form

Hi All guys,

First of all, I don't understand why but I don't see the message (fade) for the success or failed saving.
Thereafter, I need to implement the saving data without refreshing the page
This is the controller
    1. <?php
      class Admin_Controller_Cms extends IV_View_Base {

          public function 

      routesAction() {
              
      $this->assign'aRoutes'Default_Model_RouteEntity::getAllRoutes() );
              
      $this->renderTemplate'cms/routes.phtml' );
          }
          

      /**
           * ajax response action
           */
          


      public function routeupdateAction()
          {
              

      $iRoute IV_Http_Base::getParameter('id'IV_Http_Base::HTTP_POST);
              
      $sPath IV_Http_Base::getParameter('path'IV_Http_Base::HTTP_POST);
              
      $sModule IV_Http_Base::getParameter('module'IV_Http_Base::HTTP_POST);
              
      $sController IV_Http_Base::getParameter('controller'IV_Http_Base::HTTP_POST);
              
      $sAction IV_Http_Base::getParameter('action'IV_Http_Base::HTTP_POST);
              
      $iAccessRole IV_Http_Base::getParameter('accessRole'IV_Http_Base::HTTP_POST);
              
      $iRoleCompareOperator IV_Http_Base::getParameter('roleCompareOperator'IV_Http_Base::HTTP_POST);

              

      $oRoute Default_Model_RouteEntity::getInstanceById($iRoute);
              if (
      is_object($oRoute) && $oRoute instanceof Default_Model_RouteEntity) {
                  
      $oRoute->setPath($sPath);
                  
      $oRoute->setModule($sModule);
                  
      $oRoute->setController($sController);
                  
      $oRoute->setAction($sAction);
                  
      $oRoute->setAccessRole($iAccessRole);
                  
      $oRoute->setRoleCompareOperator($iRoleCompareOperator);
                  
      $oRoute->save();

                  

      $aReturn = array('valid' => 'true');
              } else {
                  

      $aReturn = array('valid' => 'false');
              }
              echo 

      json_encode($aReturn);

          }

      }



my html markup

  1. <form class="form-inline" role="form"> <form class="well form-inline"> <table class="table table-bordered" width="100%"> <tr> <th width="13%">Path</th> <th width="13%">Module</th> <th width="13%">Controller</th> <th width="13%">Action</th> <th width="13%">Access Role</th> <th width="13%">Compare Operator</th> <th width="9%">Submit</th> </tr> <? $aRoutes = $this->getValue('aRoutes'); if( count($aRoutes) == 0 ) { ?> <tr> <td colspan="7">No routes found!</td> </tr> <? } else { /** * @var Default_Model_RouteEntity $oRoute */ foreach ( $aRoutes as $oRoute) { ?> <tr> <td width="13%"> <input type="text" name="path" value="<?= $oRoute->getPath(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oRoute->getModule(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oRoute->getController(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oRoute->getAction(); ?>"/> </td> <td width="13%"> <input type="text" class="form-actions" value="<?= $oRoute->getAccessRole(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oRoute->getRoleCompareOperator(); ?>"/> </td> <td width="9%"> <input type="hidden" name="id" value="<?= $oRoute->getId(); ?>" /> <button type="button" class="btn btn-default btn-sm" id="route_update">Edit</button> <div id="comment"></div> </td> </tr> <? } } ?> </table> </form> </form> <? $this->addJs('admin/cms/route'); ?> <script type="text/javascript"> $(document).ready(function () { ROUTE.setSaveUrl('<?=IV_Url_Base::url( 'admin_cms_routeupdate' ); ?>'); ROUTE.init(); }); </script>

and the js file


  1. var ROUTE = new function () {
        var 
    oGlobal this;
        
    this.sSaveUrl '';

        

    this.setSaveUrl = function (_sUrl) {
            
    this.sSaveUrl _sUrl;
        }

        


    this.setEventSubmit = function () {
            $(
    '[id^="route_update"]').each(function () {
                $(
    this).click(function () {
                    var 
    oData = $(this).closest('tr').find('input').serializeArray();
                    
    console.log(oData);

                    

    oReq = $.post(oGlobal.sSaveUrloData, function (data) {
                        if (
    data['valid'] != "true") {
                            
    //console.log('error');
                            //Fade in
                            

    $('#comment').html('Insert Success').fadeIn(1000);
                            
    //Fade out
                            
    setTimeout(function () {
                                $(
    '#comment').html('').fadeOut(1000);
                            }, 
    1500);
                            
    //fade in
                            
    $('#comment')
                        } else {
                            

    //console.log('success');
                            //Fade in
                            

    $('#comment').html('Insert Success').fadeIn(1000);
                            
    //Fade out
                            
    setTimeout(function () {
                                $(
    '#comment').html('').fadeOut(1000);
                            }, 
    1500);
                            
    //fade in
                            
    $('#comment')
                        }
                        return 

    false;
                    }, 
    'json');

                    return 

    false;
                });
            });
        }

        




    this.init = function () {
            
    this.setEventSubmit();
        }


How do I continue to create the post url as the jquery .ajax validation inherent the php file?

Regards