Firing ajax and form submit with one button

F

facehUK

I want to be able to submit some form data and save the contents of
some lists by using a single form button.

I am using the following event listener:
$$('.savePageButton').addEvent('click', SaveLists);

and applying the class "savePageButton" to my form submit button:
<input type="submit" name="submit" value="Apply changes to Skin"
class="button1 savePageButton" />

which calls a function SaveLists to save the list via AJAX:
var SaveLists = function(e)
{
cssList = serialize('css');
jsList = serialize('js');
new Ajax('save_includes',{data: "css=" + cssList}).request();
};

However, the Ajax never seems to fire. The form submits and ignores
the ajax script...
I have tried using new Event(e).stop(); to stop the form, which
completes the AJAX, but then doesnt submit the form...

Help please, how do i do both? :)
 
M

Martin Honnen

facehUK said:
However, the Ajax never seems to fire. The form submits and ignores
the ajax script...
I have tried using new Event(e).stop(); to stop the form, which
completes the AJAX, but then doesnt submit the form...

Help please, how do i do both? :)

Try whether setting
<form target="_blank" ...>
fixes the problem.
I am not sure there is another solution, the browser (or at least some
browser) probably swallows the HTTP request once the form is submitted
to the same browser window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top