tags:

views:

46

answers:

2

Hi all, I want to make a new ajax request automatically while one ajax request is being processed (in cakephp), how can i be able to do that? I know that user can initiate multiple ajax request simultaneously, but how can i initiate a new ajax request automatically when another ajax request is made?

Below is the way, am calling one ajax function inside another, but its not working,

echo $ajax->form(array('type' => 'post', 'options' => array('model' => 'Thing',
            'url' => array('controller' => 'things', 'action' => 'xyz'),'update' => 'dy4', 'indicator' => 'ldng', 'loading' => ( $ajax->
            remoteFucntion(array('url' => array('controller' => 'stories', 'action' =>
            'keep'), 'update' => 'dy3', 'frequency' => 5))))));echo $form->input('a', array('type' => 'checkbox'));echo $form->input('b', array('type' => 'checkbox')); echo $form->end('RUN');
A: 

Go to CakePHP coockbook and look at callback options. Choose 'before', 'loading', 'complete' or whatever suits you. You'll probably have to write ajax in javascript for those parameters.

ghaxx
I have edited my question, in the code above, the remote function is not running every 5 seconds which is expected, but it runs only once if i remove the frequency option.So i tried remoteTimer function, but when i use remoteTimer fucntion, some code of the script goes outside the script tags and i see that in the webpage....
tecks
The cake code that you have pasted seems to work after fixing typo in 'remoteFunction' (at least in 1.2).
ghaxx
I've just noticed the 'frequency' thing. 'RemoteTimer' seems not to be thoutgh through... Without tweaking sources it cannot be passed as option in array.
ghaxx
A: 

Just chain the javascript calls.

Leo
I have edited my question, in the code above, the remote function is not running every 5 seconds which is expected, but it runs only once if i remove the frequency option.So i tried remoteTimer function, but when i use remoteTimer fucntion, some code of the script goes outside the script tags and i see that in the webpage....
tecks