Satish Ravipati
Satish Ravipati

Reputation: 1449

CakePHP - How to call JS function when ajax request is completed

How can i call a JS function when the ajax request is completed

I'm Using Js helper and RequestHandler Component

This is my view file

<?php echo $this->Js->submit('Create User', array(
    'before'=>$this->Js->get('#loading')->effect('fadeIn'),
    'success'=>$this->Js->get('#loading')->effect('fadeOut'),
    'update'=>'#success',
)); 
?>

i'm getting a loading message and success message... I want to call a JS function when the ajax request is done/completed, so that i can close the User registration DIV

Upvotes: 2

Views: 2563

Answers (1)

Satish Ravipati
Satish Ravipati

Reputation: 1449

i solved it...there is a method in Js Helper called complete and we can call JS function

<?php echo $this->Js->submit('Create User', array(
    'before'=>$this->Js->get('#loading')->effect('fadeIn'),
    'success'=>$this->Js->get('#loading')->effect('fadeOut'),
    'update'=>'#success',
    'complete' => 'self.setInterval("test()",2000);'
)); 

test() will be called after ajax request is completed.

Upvotes: 3

Related Questions