By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,948 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,948 IT Pros & Developers. It's quick & easy.

xmlhttp.open "GET" during browser post?

P: n/a
Hello,

Anyone know if it's possible to speak with the server via xmlhttp.open
while the browser is doing a post -- file upload in this case:

<form enctype="multipart/form-data" action="product" method="post"
name="product" onSubmit="do_action_form(); return true;">
....
<script>
// .. setup xmlhttp here.
function do_action_form() {
xmlhttp.open("GET", '/upload?file_id=173729929292')
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
}
}
xmlhttp.send(null);
}
</script>

This code works fine if not being using during a (browser) post, but
dies with:

Error: [Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::
upload/file_id=42442662626 :: anonymous :: line 356" data: no]

The purpose of this is to check the file upload status (eta / size etc)
with the server as a file is being uploaded.

Thanks,
-J
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Jason Morehouse wrote:

Anyone know if it's possible to speak with the server via xmlhttp.open
while the browser is doing a post -- file upload in this case:

<form enctype="multipart/form-data" action="product" method="post"
name="product" onSubmit="do_action_form(); return true;">
...
<script>
// .. setup xmlhttp here.
function do_action_form() {
xmlhttp.open("GET", '/upload?file_id=173729929292')
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
An alert dialog is modal and blocks the browser so it is detrimental to
use it if you want to have one request done while another is being
performed in another thread.

This code works fine if not being using during a (browser) post, but
dies with:

Error: [Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::
upload/file_id=42442662626 :: anonymous :: line 356" data: no]


Could you check whether the error goes away if you do not use alert?
If you want to output the responseText you could try
var p;
if (document.createElement && (p = document.createElement('p'))) {
p.appendChild(document.createTextNode(xmlhttp.resp onseText));
document.body.appendChild(p);
}
but I have no idea whether the browser is able to change the document
while a file upload has already been started.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
Martin Honnen wrote:
Could you check whether the error goes away if you do not use alert?
If you want to output the responseText you could try
var p;
if (document.createElement && (p = document.createElement('p'))) {
p.appendChild(document.createTextNode(xmlhttp.resp onseText));
document.body.appendChild(p);
}
but I have no idea whether the browser is able to change the document
while a file upload has already been started.


Thanks. Yeids the same results. I guess it doesn't like it when a file
is being uploaded... atleast not in Firefox anyway. Haven't tried IE.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.