ajaxSubmit doesn't submit with Firefox, submits with refresh in explorer

ajaxSubmit doesn't submit with Firefox, submits with refresh in explorer

This has been driving me insane for days, sure would appreciate any ideas:

I'm using a very basic implementation of ajaxSubmit for a form which only needs to post, but gets trickier as it is handled by a cgi script, which I know almost nothing about.

Everything works perfectly - the form is submitted and the textarea updates with the confirm message - in Chrome and Safari. Explorer does the submit, but refreshes the page. Firefox displays the confirmation message but doesn't appear to actually submit the form, as does Opera - which I'm quickly starting to not care about, haha - but of course I simply must support Firefox.

formSubmit.js
  1. $(function() {
  2. $("form#chatIn").submit(function() {
  3. $("form#chatIn").ajaxSubmit();
  4. $("textarea#Message").val('MESSAGE SENT').fadeIn('slow').click(function () {
  5. $(this).val('');
  6. });
  7. return false;
  8. });
  9. });

HTML
  1. <form id="chatIn" name="chatInForm" action="http://path/to/post.cgi" method="post">
  2. <fieldset>
  3. <textarea name="Message" id="Message" rows="2" cols="10" onfocus="this.value=''; this.onfocus=null;">Your message to the Lounge Hotline!</textarea>
  4. <input style="position:relative; top: -10px;" type="submit" name="submitButton" title="Send!" value="|| Send ||" />
  5. </fieldset>
  6. </form>

post.cgi
  1. #!/usr/bin/python
  2.   
  3. import cgi, urllib2, urllib
  4. import cgitb
  5. cgitb.enable()
  6. import os
  7.  
  8.  
  9. # This file needs to be readable and writable from this cgi
  10. file_name = "my_url"
  11.  
  12. form = cgi.FieldStorage()
  13.  
  14. # Set the URL of your form [anyone know how to get it to return to whatever page we came from?]
  15. url = "http://thePageThatStraightHTMLformWouldReturnTo.com/"

  16.  
  17. # If we haven't a Message or URL let the user know it and redirect to the form
  18. if "Message" not in form and "URL" not in form:
  19.  
  20.         print "Content-Type: text/html"
  21.         print
  22.         print "<html><head><meta http-equiv="refresh" content="5; URL=%s"></head>" %url
  23.         print "<body style="text-align: center; margin-top: 20px;">"
  24.         print "Please fill in the message field.<br><a href="%s">Redirection to the form in 5 seconds</a>" %url
  25.         print "</body></html>"
  26.  
  27. # If we have URL param then this is an URL update
  28. elif "URL" in form: 
  29.         # Intercept errors
  30.         try:
  31.                 # Write the url to the file, overwriting the existing file. 
  32.                 f = open(file_name,'w')
  33.                 f.write(form["URL"].value)
  34.  
  35.                 # Let the caller know it worked.
  36.                 print "Content-Type: text/html"
  37.                 print
  38.                 print "OK"
  39.         except:
  40.                 # it has an error.
  41.                 print "Content-Type: text/html"
  42.                 print
  43.                 print "ERROR|%s" %file_name
  44.  
  45. # We have Message then this is a status update.
  46. else:
  47.         # Redirect back to the form
  48.         print "Status: 302 Moved"
  49.         print "Location: %s" %url
  50.         print
  51.  
  52.         # Read in the url from the file
  53.         f = open(file_name,'r')
  54.         base_url = f.read()
  55.  
  56.         # Build the complete url with query args.
  57.         message = form["Message"].value
  58.         args = "?Message=%s" % urllib.quote(message)
  59.  
  60.         # Make the request, giving the status to the script.
  61.         response = urllib2.urlopen(base_url + args)
    • Topic Participants

    • kyle