That's easy, your code is adding the event each time.  Each time the link is
clicked it adds a new copy of the event.

The 4th time there will be 4 events..  etc


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of praveen
Sent: Friday, March 19, 2010 1:44 PM
To: MooTools Users
Subject: [Moo] ajax submit issue

Hi, I am submiting a form on click of hyperlink using ajax call. the
issue is, first time it works fine. Second time i click the link the
event is firing twice and submiting twice. 3rd time it submits 3
times..and so on..I am not getting why it is happening. Here is the
hyperlink and its code.. Let me know where i am doing wrong.

        function processFormAjaxCall(remoteUrl, targetDiv, formId, method) {
                alert("form submit" + remoteUrl + ":" + targetDiv);
                var request = new Request.HTML({
                    url: remoteUrl,
                    update: targetDiv,
                    method: method
                });

                $('addAtty').addEvent('click', function(event){
                        if (event) {
                                event.stop();
                                event.preventDefault();
                        }
                    request.post($(formId)); //This code is executing more
than once
time as i keep clicking my hyperlink.
                });
        }


Hyperlink in my jsp look like this(like a normal link, but just
incase)
        <a id="addAtty" href="#" class="addmore"
onclick="processFormAjaxCall('addMoreItems.action',
'resultList','frmId','POST' )">Add More Items</a>&nbsp;&nbsp;


I click the hyperlink id: "addAtty" to trigger the ajaxcall. Please
let me if some help me to figure out whats happening, is it a ajax
issue or something else.

To unsubscribe from this group, send email to
mootools-users+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.

To unsubscribe from this group, send email to 
mootools-users+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to