Current location: Hot Scripts Forums » General Web Coding » JavaScript » Prototype.js - Event.stop doesnt work with IE


Prototype.js - Event.stop doesnt work with IE

Closed Thread
  #1 (permalink)  
Old 06-01-07, 07:21 AM
Agum Agum is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Prototype.js - Event.stop doesnt work with IE

Hi all,

I have a quick question/problem.
So I have a login form. Here's my JS:

Javascript Code:
  1. Event.observe(window, 'load', init, false);
  2.  
  3. function init()
  4. {
  5. Event.observe('loginForm', 'submit', loginAction);
  6. }
  7.  
  8. function loginAction(event)
  9. {
  10. Event.stop(event);
  11. // do other stuff
  12. }

This doesn't work in IE.
It works fine in Firefox, stopping the form from submitting at that time, and run rest of the function. In IE, the form just submits. How can I fix this?

Thanks.

Last edited by UnrealEd; 06-01-07 at 07:38 AM. Reason: please use the [highlight=Javascript] wrapper when posting javascript code
  #2 (permalink)  
Old 06-01-07, 07:34 AM
Vicious's Avatar
Vicious Vicious is offline
Community VIP
 
Join Date: Jan 2007
Location: Belgium
Posts: 584
Thanks: 0
Thanked 0 Times in 0 Posts
what happens if you add: return false; to loginAction ?
__________________
Jack Bauer makes Chuck Norris cry
  #3 (permalink)  
Old 06-01-07, 01:57 PM
Agum Agum is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Tried that, still doesn't work.
  #4 (permalink)  
Old 06-01-07, 08:56 PM
Agum Agum is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Update:

I just found out that above piece of code works, what doesn't work is what follows in the "other stuff" part, which I have this:

javascript Code:
  1. var loginAjax = new Ajax.Request('/foobar/url', {
  2.         method: 'post',
  3.         parameters: {user: $('username').value},
  4.         onSuccess: function(transport) {
  5.             $('errorMsg').innerHTML = transport.responseText;
  6.         },
  7.         onFailure: function() {
  8.             $('errorMsg').innerHTML = 'Failed.';
  9.         },
  10.         });

In FireFox, it would work fine and the errorMsg would update accordingly.
However, in IE, it just redirects to the /foobar/url page, as if AJAX is not used at all and the form just got submitted..
  #5 (permalink)  
Old 06-01-07, 09:20 PM
Agum Agum is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry, please close thread, problem solved. It was a syntax bug. Not sure why it worked in Firefox.
  #6 (permalink)  
Old 06-01-07, 10:04 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Closed by request.
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freelance PHP Developer needed to work with Amberfly Ltd petebarr Job Offers & Assistance 3 07-03-09 12:23 PM
The Art Nexus seeking PHP programmers TheArtNexus Job Offers & Assistance 5 02-26-08 03:08 AM
I'm desperate for work, I'll do any work for cheap [PHP/MySQL] Anastas Job Offers & Assistance 17 02-12-06 11:18 AM
Grab data from mysql resualt and How to make this eregi work ? websnow PHP 12 01-08-05 12:44 PM


All times are GMT -5. The time now is 11:27 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.