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
onSubmit='return returnTrueIfAJAXDoesNotWork()' - doesn't wo

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


Joined: 24 Sep 2007
Posts: 2

PostPosted: Mon Sep 24, 2007 2:22 pm    Post subject: onSubmit='return returnTrueIfAJAXDoesNotWork()' - doesn't wo Reply with quote

Based on the code at A List Apart, my AJAX code follows the structure outlined below. This is fine in IE, but not in Firefox and I can't figure out what's going on. I have two lines of inquiry:

1. For some reason, Firebug stops stepping through the code after executing the request.open() instruction. However, if I put an alert into the request.onreadystatechange function, or the handler, I still get the alert. Any thoughts why?

2. The above would not be a problem, except that the application doesn't work. I've traced the problem to the form's onsubmit - Firefox doesn't return true to the onSubmit, causing the form to submit, meaning that any visual changes to the page made in the handler disappear. Thus, Firefox appears to execute all the code that results from the sendRequest() instruction, but fails to complete the rest of the code in the loginUser() function - namely the return true; instruction. However, because of the above issue with Firebug, I can't confirm what's going on. Any thoughts?

Cheers,
Iain


Code:
<form onSubmit="return !loginUser();">

function loginUser() {
   if (request = createHTTPRequest()) {
      sendRequest(request, "POST", loginHandler, url, parameters);
      return true;
   }
   return false
}

function sendRequest (request, method, loginHandler, url, parameters) {
   try{
      request.onreadystatechange = function () {
         if (request.readyState == 4) {
            if (request.status == 200) {
               handler(request);
            } else {
               // handle error
            }
         }
      };
      request.open(method, url, true);
      request.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
      request.send(parameters);
   } catch (e) {
      // handle error
   }
}
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
 Advertisements
 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 ?


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