Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
Stopping a form from submitting with unobtrusive javascript?

Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
New one
New one

Joined: 03 Nov 2006
Posts: 1

PostPosted: Fri Nov 03, 2006 3:52 pm    Post subject: Stopping a form from submitting with unobtrusive javascript? Reply with quote


I found this website after search on the internet for ages for an answer for my question.

I'm building a simple AJAX mailing list application using prototype, and I'm trying to implement unobtrusive javascript. Prototype's Event.observe function works well when I load the page and when I submit a form, but fails to return a value to stop the page from processing normally. Here's the code I have:

<div id="list">
   <form method="get" name="joinform" action="join.php" id="joinform">
      <label>Name:</label> <input type="text" name="name" id="name" />
      <label>Email:</label> <input type="text" name="email"id="email" />
      <button type="submit">Join mailing list</button>
   <div id="processing" style="display: none">

AJAX (prototype library included in the <head>):
   function() {
function ajaxer() {
   var params = 'name='+ escape($F('name'));
   params += '&email='+ escape($F('email'));
   params += '&ajax=true';
   var a = new Ajax.Updater(
         asynchronous: true,
         method: 'get',
         parameters: params,
         evalScripts: true
   return false;

I know the code works, because while testing I added an alert call into my ajaxer method, and it stopped the page from processing but allowed the ajax call to continue. Once I clicked the alert, the form continued to process.

I know I can use onsubmit="return ajaxer();", but I want to make it unobtrusive.

Any thoughts and advice is very much appreciated.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 XML & Copyright Notice 

Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X

Link to our site:


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos

Normal Bookmark

Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax

Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?

it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert