tags:

views:

721

answers:

3

Hello all,

I am using Firefox and I've been reading some forums claiming this doesn't work in firefox but it has been working for me for the last few days but has stopped working and I can not figure out why.

I make a AXAX POST Request using an IFrame. When I get the response I use this:

function startLoad(){
    $.get("update.php", function(data){
      if(data==''){
       startLoad();
      }
      else{
       document.getElementById("tweetform").submit();
      }
    });
}

However, from firebug, I get this:

document.getElementById("tweetform").submit is not a function
[Break on this error] document.getElementById("tweetform").submit();

I know submit exists, but what is going on?

Thanks all

A: 

I guess you are using jQuery.

Try this instead.

$("#tweetform").submit();
Elzo Valugi
That is the same as document.getElementById("tweetform"), so if that fails, running the jQuery equivalent does not make a difference.
ichiban
And yet people still vote it up. Ridiculous.
Josh Stodola
well.. this kind of error that the guy had wouldn't have happend using the syntax that I recommended.
Elzo Valugi
I don't believe it — but I'll test just to make sure — and I'm right. It wouldn't fix it.
David Dorward
+8  A: 

My guess would be that you have an element in the form that is called "submit" (possibly a <button> or <input type="submit">, and that ".submit" is retrieving a reference to that element, rather than the member function "submit()". If this is the case, try renaming that element to something else (e.g., "submit_button").

Jason Musgrove
Good call. I have been bitten by this before.
harto
We have a genius here! :) You are right, I had a button with name attribute "submit"! But what is the use of getElementById if it doesn't reference that element! :P
Abs
It does. Your problem is that `myForm.submit` is another element and not a function that submits the form.
David Dorward
A: 

Use document.forms['tweetform'].submit() instead

Alex G
Accessing the HTMLFormElement object a different way isn't going to make the submit method magically start working.
David Dorward