You could do one Ajax request -- send the form elements and update the cart area (I'm guessing that's what you're doing here) with the return from that post:

var myForm = $(form);
new Ajax.Updater('items_container', 'servlet.do?storeItemId', {parameters:myForm.serialize()});

Just be sure that the result returned by your server method is the HTML that you want to have in the items_container div. That may require some rejigging of your servlet method, perhaps a redirect after a post to the list or view or whatever you call it method.

This JS is off the top of my head, but it should work just fine. By the way, method:post is default, you never need to put that in a set of parameters.

Walter

On Feb 2, 2011, at 10:11 AM, jcl wrote:

Hi all

I have to execute an action on server before update a div of my jsp
page.
With this approach it work,but the question is....is there a better
approach to solve this problem?

This is my working code:

function ajaxSubmit(){

                var form = document.forms[0];
                form.id = 'myForm';
                form.action = 'servlet.do?storeItemId';
                $('myForm').request({ onComplete: function(){
                                                                                
        new Ajax.Updater('items_container','pages/showItems.jsp',
{ method: 'post' });
                                                                                
 }
                 });

        }

Thank you for help!

--
You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com . To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en .


--
You received this message because you are subscribed to the Google Groups "Prototype 
& script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to