Yii Framework Forum: How To Call Ajax - Yii Framework Forum

Jump to content

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

How To Call Ajax Rate Topic: *---- 1 Votes

#1 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 12:21 AM

Hi, i need to display my file in single page. In my application i've some options, when i click option i need to display anothe page in the same page only.

Here i'm attaching my files. Here i've seeting page inthat when i click change password the password page need to display in setting page only by using ajax. can i know how to use ajax here?

Attached File(s)


0

#2 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 19-February 13
  • Location:India

Posted 21 May 2013 - 02:32 AM

Hi there,

First Step
<div class="inner_tab_contant">
Passwrid page 
</div>

Second Step in password page
<?php echo CHtml::ajaxLink(' Add Artist', array('artist/addartist?vid=' . $vid), array('update' => '.inner_tab_contant'), array("live" => false)); ?>


Third Step
Then you can create the action in your controller and render the setting page

public function actionaddartist(){
$this->render('setting');
}


Best Regards,
Ankti Modi
Thanks,
Ankit Modi
Skype : amodi06
0

#3 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 03:11 AM

Hi, it's not working...
0

#4 User is offline   Ghanshyam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 18-March 13
  • Location:Ahmedabad

Posted 21 May 2013 - 03:29 AM

Hi,

if you want to replace setting.php with password.php,
make like,
in setting.php

<html>
    <body><br><br><br>
        <table>
      <div id="anyid">
        
        <table align="left">
        </table>

      </div>
            </table>
        </body>
    </html>


and you want to keep your <table> data
so put that <div id="anyid"> after </table> tag

Now,

call ajax on click button

ajax call in javascript

 $.ajax({
  type: 'GET',
  url: '<?php echo CController::createUrl('controlelr/action'); ?>',
  asyc: false,
  data: {'c': c},
  success: function(data) {
   if(data){
    $('#anyid').html(data);
   }
  }
 });


in controller action--

call your password page like

$this->renderPartial('password',array('model'=>$model));

0

#5 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 04:07 AM

No. i don't need to replace in setting page. In setting page i've Change Password link, when i click link the password page also need to display in setting page with functionality of Change Password.
0

#6 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 19-February 13
  • Location:India

Posted 21 May 2013 - 04:36 AM

1) Just change link to ajax link in your setting.php
<?php echo CHtml::ajaxLink(' change password', array('/user/password'), array('update' => '.inner_tab_contant'), array("live" => false)); ?>


2) At the end of page you can append the div

just add the div at the end of page

<div class="inner_tab_contant"></div>


3) in your user controller renderpartial page

=>$this->renderPartial('/user/password', array('model' => $model,true,false));


BestRegards,
Ankit Modi

Thanks,
Ankit Modi
Skype : amodi06
0

#7 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 05:22 AM

View PostAnkit Modi, on 21 May 2013 - 04:36 AM, said:

1) Just change link to ajax link in your setting.php
<?php echo CHtml::ajaxLink(' change password', array('/user/password'), array('update' => '.inner_tab_contant'), array("live" => false)); ?>


2) At the end of page you can append the div

just add the div at the end of page

<div class="inner_tab_contant"></div>


3) in your user controller renderpartial page

=>$this->renderPartial('/user/password', array('model' => $model,true,false));


BestRegards,
Ankit Modi


Dear Ankit Modi,
In userController where i need to change.
0

#8 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 19-February 13
  • Location:India

Posted 21 May 2013 - 05:37 AM

In your Usercontroller go to actionpassword and add one line before close the action bracket

$this->renderPartial('/user/password', array('model' => $model,true,false));

Thanks,
Ankit Modi
Skype : amodi06
0

#9 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 05:58 AM

View PostAnkit Modi, on 21 May 2013 - 05:37 AM, said:

In your Usercontroller go to actionpassword and add one line before close the action bracket

$this->renderPartial('/user/password', array('model' => $model,true,false));


Dear Ankit Modi,
Now i am getting in the same page, but when i click button my page action is showing in anothe page. it showing like this in my anothe page

Fields with * are required.
Current Password *

New Password *

Confirm Password *

BUt, my password is saving successfully. But, i need to show in same page.
0

#10 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 06:10 AM

View PostAnkit Modi, on 21 May 2013 - 06:06 AM, said:

Sorry,

u can try the render page not in renderpartial


Hi, i changed render, it displaying same page. But, it showing anothe page when i click submit button.
0

#11 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 06:12 AM

When click submit button i need to stay in same page
0

#12 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 19-February 13
  • Location:India

Posted 21 May 2013 - 06:16 AM

u can chnage this line in your password form

<?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        
        'id' => 'changePass-form',
        'type' => 'horizontal',
        'enableAjaxValidation' => false,
        'htmlOptions' => array(
                'onsubmit' => "return false;",
            ),
    ));
    ?>

Thanks,
Ankit Modi
Skype : amodi06
0

#13 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 06:22 AM

View PostAnkit Modi, on 21 May 2013 - 06:16 AM, said:

u can chnage this line in your password form

<?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        
        'id' => 'changePass-form',
        'type' => 'horizontal',
        'enableAjaxValidation' => false,
        'htmlOptions' => array(
                'onsubmit' => "return false;",
            ),
    ));
    ?>


Hi, when i gave like this My submit button action is not working.
0

#14 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 19-February 13
  • Location:India

Posted 21 May 2013 - 06:25 AM

yes i know because it's return false so u can just add the line validate on submit using clientoptions


<?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        
        'id' => 'changePass-form',
        'type' => 'horizontal',
        'enableAjaxValidation' => false,
 	'clientOptions' => array(
                'validateOnSubmit' => true,
              
            ),
  	'htmlOptions' => array(
                'onsubmit' => "return false;",
            ),
    ));
    ?>

Thanks,
Ankit Modi
Skype : amodi06
0

#15 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 06:30 AM

View PostAnkit Modi, on 21 May 2013 - 06:25 AM, said:

yes i know because it's return false so u can just add the line validate on submit using clientoptions


<?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        
        'id' => 'changePass-form',
        'type' => 'horizontal',
        'enableAjaxValidation' => false,
 	'clientOptions' => array(
                'validateOnSubmit' => true,
              
            ),
  	'htmlOptions' => array(
                'onsubmit' => "return false;",
            ),
    ));
    ?>


No, Sir, Now also submit action is not working. when i click submit it's nothing happend?
0

#16 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 19-February 13
  • Location:India

Posted 21 May 2013 - 06:34 AM

and finally last change the line in your password action

$this->renderPartial('/user/password', array('model' => $model),false,true);


hope this help
Thanks,
Ankit Modi
Skype : amodi06
0

#17 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 06:37 AM

Now also action is not working, sir. if i put comments to htmlOptions the action is working, but, the page is displaying in another page.
0

#18 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 06:57 AM

Sorry, sir, i'm not getting, from where i need to add onclick function here...

<?php echo CHtml::link('Change Password', array('/user/password', 'id' => app()->user->id), array('update' => '.inner_tab_contant'), array("live" => false)); ?>
0

#19 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 19-February 13
  • Location:India

Posted 21 May 2013 - 07:01 AM

First change the line on password.php
<?php echo CHtml::link('Link Text',array('user/password?id=942'),array('class'=>'aa','onclick'=>'test()')); ?>


and add the function
<script>
function change(id) {
            if (id != '') {
                $.ajax({
                    type: "GET",
                    url: "<?php echo Controller::createUrl('/users/password') ?>",
                    data: {"id": id},
                    async: false,
                    success: function(data) {
                        $('.inner_tab_contant').html(data);
                    },
               });
            }
        }
</script>

Thanks,
Ankit Modi
Skype : amodi06
0

#20 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 21 May 2013 - 07:06 AM

ohhh, Its opening in new page and also action is not working.
0

Share this topic:


  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users