tags:

views:

29

answers:

1

am trying to run the remote function in the code below every 5 seconds, but it runs only once if i remove the frequency option. So i tried remoteTimer function, but when i use remoteTimer function, some code of the script goes outside the script tags and i see that in the webpage..

echo $ajax->form(array('type' => 'post', 'options' => array('model' => 'Thing',
        'url' => array('controller' => 'things', 'action' => 'xyz'),'update' => 'dy4', 'indicator' => 'ldng', 'loading' => ( $ajax->
        remoteFunction(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');

if in case, this cannot be done using cakephp helpers, how can i do it with javascript?
ps(am not good at javascript, so if someone could show me the code, that will be helpful)

+1  A: 

Use remoteTimer in a very simple controller. See the page source and between <script> tags you'll get code that does what you want.You can use that code as value for "loading" option.

ghaxx
Thanks ghaxx, i tried that but its not working, belwo is my code, can you help me in figuring out y its not working, echo $ajax->form(array('type' => 'post', 'options' => array('model' => 'Thing','url' => array('controller' => 'things', 'action' => 'xyz'), 'id' =>'chooseDateForm', 'name' => 'chooseDateForm', 'update' =>'dy4', 'indicator' => 'ldng', 'loading' => 'show()')));and below is the code for remote timer, fucntion show(){ //<![CDATA[new PeriodicalExecuter(function() {new Ajax.Request('/bt/db/stories/keep', {asynchronous:true, evalScripts:true})}, 10)//]]>}
tecks
Well... I meant the code between `<script>` tags that is actual javascript. :) So literally it's between `<script>//<![CDATA[` and `//]]></script>`. I wonder, too, if your code has more line breaks than the one visible in here. At least this one in here is not very readable.
ghaxx