You are not alone. I just posted this.
http://groups.google.com/group/cake-php/browse_thread/thread/08b7b0da95bac850#

On Nov 21, 12:48 pm, huoxito <[email protected]> wrote:
> I've stopped one more time again to try to understand and use the Js
> helper for ajax requests but it seems I just cant get it, and still
> couldnt find a good example of its use with ajax on the web. Every
> time I have to do one request I need to write all this bunch of code:
>
> $.ajax({
>
>                 url: '<?php echo $html->url(array("controller" =>
> "agendamentos","action" => "editResponse"));?>',
>                 cache: false,
>                 type: 'GET',
>                 contentType: "application/x-www-form-urlencoded;
> charset=utf-8",
>                 data: ( {id : id, categoria: categoria, valor: valor,
> vencimento: vencimento, observacoes: obs} ),
>                 beforeSend: function(){
>                     $('.submit img').remove();
>                     $('.submit span').remove();
>                     $('.submit').append('<img style="float: left;
> margin-left: 15px;" src="../../../<?php echo IMAGES_URL;?>ajax-
> loader.gif" title="excluindo ... " alt="excluindo ... " />');
>                 },
>                 success: function(result){
>
>                     if(result == 'error'){
>                         $('.submit img').fadeOut('fast', function(){
>                                 $('.submit').append('<span
> class="ajax_error_response">Ocorreu um erro. Recarregue a página e
> tente novamente.</span>')
>                             });
>                     }else if(result == 'validacao'){
>                         $('.submit img').fadeOut('fast', function(){
>                                 $('.submit').append('<span
> class="ajax_error_response">Preencha todos os campos corretamente.</
> span>');
>                             });
>                     }else{
>
>                         parent.$('#agend-' + id).html(result);
>                         //var te=setTimeout("parent.$('#agend-'" + id
> +").html("+ result +");",5000);
>                         var
> t=setTimeout("parent.jQuery.fn.colorbox.close()",100);
>                     }
>
>                 }
>
>             });
>
> which doesnt seems practical at all. I'm really enjoying study and
> work with cakephp but I guess its lack of builtin ajax functions is
> what bothers me most so far. Hope to improve that myself by developing
> a helper which would make things simpler, clearer and share it with
> the community.
>
> Just curious, Do you get to use much of Js helper on your projetcs ?
> Or I'm the only one here who doesnt get along well with it?
>
> On 28 set, 18:41, lyba <[email protected]> wrote:
>
>
>
>
>
>
>
> > for the record:
> > Seems that above function despite having additional class is still
> > bound to the same event executing both open and close.
>
> > Since I could not find solution to this in reasonable time I've
> > implemented following workaround:
>
> > $(function()
> > {
> >         $('div.Commands a.CmdOpen').click(function(ev)
> >         {
> >                 ev.preventDefault();
> >                                 var target = 
> > $(this).parent('div').next('div.Target');
> >                                 if ($(this).is('.Active')) {
> >                                         $(this).removeClass('Active');
> >                                         target.slideUp().html('');
> >                                 } else {
> >                                         $(this).addClass('Active');
> >                                         
> > $("#busy-indicator").clone().appendTo(target).show();
> >                                         $.ajax({
> >                                                         url: 
> > $(this).attr('href'),
> >                                                         cache: false,
> >                                                         success:
> >                                                                         
> > function(html)
> >                                                                         {
> >                                                                             
> >             target.slideDown().html(html);
> >                                                                         },
> >                                                         error:
> >                                                                         
> > function (XMLHttpRequest, status, errorThrown)
> >                                                                         {
> >                                                                             
> >             alert('error ...');
> >                                                                         }
> >                                         });
> >                                 }
> >         });
>
> > });
>
> > At present I only experience one problem - indicator is visible only
> > on the first click, following clicks work but do not display busy
> > indicator while awaiting ajax response.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to