473,391 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,391 software developers and data experts.

xmlhttp.open "GET" during browser post?

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
2 2878


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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pete Mahoney | last post by:
Ok I use a textarea to store data input by the user, and then upon them clicking the submit button I store this data to a database. The problem is once the user inputs too much data (about 3...
3
by: Greg Alaksdjflk | last post by:
How do I create a form that allows one to submit a form, then press the "BACK" button on the browser, and allow the user to see the data he posted? It seems as though this information is lost. ...
6
by: Eitan | last post by:
Hello, I would like to know about the methods : post and get of ASP. What is the difference between them. Need some samples, and explanation, please. Thanks :)
2
by: Tom S | last post by:
I'm using ASP.NET with C# as my code behind and I figure out how to get the above process to work. I've found many examples online for using the 'method' member to "POST", but none for setting it...
5
by: Jeff | last post by:
Visual Studio 2003 DotNet framework 1.1 Windows 2000 Pro I create two pages in an Asp.net application, one is html page with a form in it: .... <form id="testForm" method="post"...
3
by: melton9 | last post by:
I'm trying to send a "get" through webbrowser1. I'm really not sure how to do this. I'm trying to emulate a button click on a page with a lot of frames. When you click the refresh button it...
10
by: rup | last post by:
Hello, This is my first application on socket programming in vc++. I am facing problem that how to make connection to server, & make GET/POST request by HTTP. Please help me. Its urgent.......
1
by: Jim Carlock | last post by:
Let's not argue about semantics. Let's talk about semasiology. Do specifications exist for using mixed case, upper case, lower case for the contents of the method employed? My own preferences...
3
by: Bsr | last post by:
What is the difference between for the following methods. "GET", "HEAD", "PUT" or "POST". Ex:my $req =HTTP::Request->new(GET =>$url1); Bhuvan.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.