1

I'm using a greasemonkey script to load a page with ajax and automatically fill in the form fields inside the page and submit the form. The problem is that when the form.submit() statement is executed I get an uncaught exception error:

"uncaught exception: [Exception... "Component is not available"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"
         //location: "JS frame ::
file:///home/user/.mozilla/firefox/kwrkmbls.default/extensions/%7Be4a8a97b-f2ed-450b-b12d-ee082ba24781%7D/components/greasemonkey.js
:: anonymous :: line 375"  data: no]" 

Strangely, if I don't use ajax to load the page, but load it manually instead, the same code works; All fields are filled in and the form is submitted.

Any idea what's at fault;

Moayad Mardini
  • 7,271
  • 5
  • 41
  • 58
flyon
  • 31
  • 3

1 Answers1

0

you can't just to request the content and try to execute it. you need to append it to the current page. something like:

document.body.appendChild(iframe);
iframe.addEventListener("load", function(e)
{
    e.target.contentDocument.forms.namedItem("namedForm").submit();
}, false);

havent tested it but you got the idea

w35l3y
  • 8,613
  • 3
  • 39
  • 51