Since, loadOneTab()
is not available for formData
,
- How can
formData
be posted to a new tab? - How can the above new tab foreground/background status be set?
Just a smaple example from Using FormData Objects:
var formData = new FormData();
formData.append("username", "Groucho");
formData.append("accountnum", 123456); // number 123456 is immediately converted to string "123456"
// HTML file input user's choice...
formData.append("userfile", fileInputElement.files[0]);
// JavaScript file-like object...
var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file...
var blob = new Blob([content], { type: "text/xml"});
formData.append("webmasterfile", blob);
var request = new XMLHttpRequest();
request.open("POST", "http://foo.com/submitform.php");
request.send(formData);
Clarification:
Normal HTML form with a target="_blank"
will POST the form data to a new tab.
Similarly, as mentioned, loadOneTab()
can also POST data to a new tab.
Is it possible to do so with XMLHttpRequest?
XHR has absolutely nothing to do with tabs. If you really want to XHR it, then you should take the returned source and update document of the target tab with it.
Otherwise I would just use
loadOneTab
: I would think something like this where things are turned into nsIFile:Import
encodeFormData
function form here: https://stackoverflow.com/a/25020668/3791822