473,725 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xmlhttp problem using Mozilla ... responseText is always null

Greetings,

I'm having a problem when I try to GET a file from my server
via xmlhttp when using Mozilla. With IE I can get any type of file
fine, get/display headers fine, etc. With Mozilla, using the same
HTML/JS it always returns no data (xmlhttp.respon seText is null).

When I try to get headers using Mozilla or display the http status code
I get some obscure exception in the javascript console that I've given
up on searching for an answer to ....

Error: [Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
http://myserver.com/xmlhttp.html? :: RSchange :: line 26" data: no]
Source File: http://myserver.com/xmlhttp.html?
Line: 26

I've tried coding my test app many ways based on the examples out there
and haven't been able to get it to run in Mozilla/FF yet.

If I do an alert on xmlhttp.respons eText I get a blank alert pop up, if
I alert xmlhttp.respons eText.length it's always zero using Mozilla.
Both alerts always work with the same HTML/JS when running in IE.

Beginning to think maybe I'm lacking something on the server side
related to Content-type being sent back that IE allows and Mozilla
doesn't(?)

Any assistance at this point would be greatly appreciated.

Thanks !
Steve

Here's a simple example that works in IE but returns null for
responseText in Mozilla when I run it ...

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JAVAS CRIPT" type="text/javascript">
<!--
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_vers ion >= 5)
// JScript gives us Conditional compilation, we can cope with old IE
versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest! ='undefined') {
xmlhttp = new XMLHttpRequest( );
}

function RSchange() {
if (xmlhttp.readyS tate==4) {
//if (xmlhttp.status == 200) {
//alert(xmlhttp.s tatusText); // this line chokes in Mozilla
alert(xmlhttp.r esponseText); //empty alert box using Moz
// }
}
}

function go() {
if (xmlhttp) {
xmlhttp.open("G ET", "http://myserver.com/index.html", true);
xmlhttp.onready statechange=RSc hange;
xmlhttp.send(nu ll);
}
}
//-->
</script>

</head>
<BODY>

<FORM NAME='' ACTION='' onsubmit="retur n true;">
<INPUT TYPE="SUBMIT" VALUE='getit' onclick="go()"
</FORM>

</BODY>
</HTML>

Jul 23 '05 #1
9 5579


fochie wrote:

I'm having a problem when I try to GET a file from my server
via xmlhttp when using Mozilla. With IE I can get any type of file
fine, get/display headers fine, etc. With Mozilla, using the same
HTML/JS it always returns no data (xmlhttp.respon seText is null).

When I try to get headers using Mozilla or display the http status code
I get some obscure exception in the javascript console that I've given
up on searching for an answer to ....

Error: [Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
http://myserver.com/xmlhttp.html? :: RSchange :: line 26" data: no]
Source File: http://myserver.com/xmlhttp.html?
Line: 26
Which line exactly is that line 26, how does the code in that line look
when you get that error message?
Are you using frames or popup windows?
I've tried coding my test app many ways based on the examples out there
and haven't been able to get it to run in Mozilla/FF yet.

If I do an alert on xmlhttp.respons eText I get a blank alert pop up, if
I alert xmlhttp.respons eText.length it's always zero using Mozilla.
Both alerts always work with the same HTML/JS when running in IE.

Beginning to think maybe I'm lacking something on the server side
related to Content-type being sent back that IE allows and Mozilla
doesn't(?)

Any assistance at this point would be greatly appreciated.

Thanks !
Steve

Here's a simple example that works in IE but returns null for
responseText in Mozilla when I run it ...

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JAVAS CRIPT" type="text/javascript">
<!--
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_vers ion >= 5)
// JScript gives us Conditional compilation, we can cope with old IE
versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest! ='undefined') {
xmlhttp = new XMLHttpRequest( );
}

function RSchange() {
if (xmlhttp.readyS tate==4) {
//if (xmlhttp.status == 200) {
//alert(xmlhttp.s tatusText); // this line chokes in Mozilla
alert(xmlhttp.r esponseText); //empty alert box using Moz
// }
}
}

function go() {
if (xmlhttp) {
xmlhttp.open("G ET", "http://myserver.com/index.html", true);


Is http://myserver.com/index.html on the same server as the HTML
document with the script? What content type does the server deliver
index.html with?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Line 26 is the following -
if (xmlhttp.status == 200) { (sorry, I also put the comment on the
wrong line in the snippit above)

Not using frames.

The page I'm trying to retrieve is on the same server (same dir also)
as the html containing the xmlhttp call.

Not sure what content type is being used by the server for delivering
index.html. Is this an Ap[ache directive ?
Maybe I should issue an xmlhttp HEAD call using IE (since Moz fails
with the same error msg mentioned above if I try to do a HEAD request)
and see what Content type is being returned ?

Thanks for the reply !
Steve

Jul 23 '05 #3


fochie wrote:
Line 26 is the following -
if (xmlhttp.status == 200) { (sorry, I also put the comment on the
wrong line in the snippit above)

Not using frames.

The page I'm trying to retrieve is on the same server (same dir also)
as the html containing the xmlhttp call.

Not sure what content type is being used by the server for delivering
index.html. Is this an Ap[ache directive ?
Maybe I should issue an xmlhttp HEAD call using IE (since Moz fails
with the same error msg mentioned above if I try to do a HEAD request)
and see what Content type is being returned ?


If that is an HTML page you can simply load it in a Mozilla window and
then check page info for details on the content type Mozilla receives.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
When I issue the following HEAD equest in IE it returns -
Content-Type: text/html
If I issue the same request in Moz it throws this in the javascript
console-

Error: [Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.getAllRespon seHeaders]"
nsresult: "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
http://timegonebuy.com/javascript_XML.html? :: anonymous :: line 123"
data: no]
Source File: http://timegonebuy.com/test_javascript_XML.html?
Line: 123

This is Line 123 -

alert('header returned is ' +xmlhttp.getAll ResponseHeaders ())

Here's what was issues -

try {

xmlhttp.open("H EAD", "http://myserver.com/index.html",tru e);
xmlhttp.onready statechange=fun ction() {
if (xmlhttp.readyS tate==4) {
alert('header returned is ' +xmlhttp.getAll ResponseHeaders ())
}
}
xmlhttp.send(nu ll)
}
catch (e) { alert('failed') ; }

Jul 23 '05 #5
bring up the html in Mozilla and using Page Info shows type - text/html

Jul 23 '05 #6
VK
How do you start your script? Is it a form button click? Of what type?

Jul 23 '05 #7
from the snippit above ... this is how the function gets invoked ...
maybe I have this twisted up
since it's type=submit and also has an onclick ? -
..
..
..
</head>
<BODY>
<FORM NAME='' ACTION='' onsubmit="retur n true;">
<INPUT TYPE="SUBMIT" VALUE='getit' onclick="go()"
</FORM>
</BODY>
</HTML>
Thanks for the reply ... hope someone can help me get past this soon
.... been bangin my head against it for over a week

Jul 23 '05 #8
THAT WAS THE PROBLEM ! .... I changed it to "type=butto n" and now the
file is received/displayed in Mozilla ... thanks for the pointer !!!!!
... obviously I need to pay more attention to the basic HTML pieces as
well ... IE must be forgiving in this scenario .... thanks again !!!!

Jul 23 '05 #9
VK
Glad it helped.
Just to make sure you got the problem right (to not repeat it):

...
form.submit();
some code after
....

or

....
document.locati on.hred = someURL;
some code after
....

are equally wrong, because the first statement clears the current DOM /
script data. It's like trying to continue the conversation with a
person after you shoot him in the temple. Some "post mortum" may occur
(script is still working) because a part of code was retained in the
program cache (orphaned script). But you cannot make any reliable
accumptions about it.

Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2240
by: jw56578 | last post by:
anyone have a code example of using xmlhttp with mozilla, if i use the following code, the function is never called, but it does work in IE. xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { var response = xmlhttp.responseText; divResponse.innerHTML += "<p>" + response + "</p>";
12
13797
by: Botan Guner | last post by:
Hi all, Here is the problem, i'm using Microsoft.XMLHTTP for ie and XMLHttpRequest for mozilla, on my local server which is win2000 server i've no problem with that but when i uploaded the file to the web server of our company which is redhat 9 i still have no problem with mozilla but the ie gives an error like this, System error: -1072896658
1
4927
by: Ike | last post by:
Ive copied an online example for writing out a php file, programmatically, then would like to re-display that data in a browswer window that automatically refreshes as the data file (getdata.php, which is the file I am programmatically rewriting to elsewhere) gets changed. I am trying to use AJAX and JSON to do this. I have copied an example of using HttpRequest Object as the backbone of this from...
3
19048
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field on my webpage. I get back that my readyState is 4 and my status is 200 and status text is "OK", but my responseText is always empty. Both on FireFox and IE7, so it must be something I'm doing (wrong). I've also set up an IFRAME to redirect the...
1
9034
by: farghal | last post by:
Hello as many people I'm new to ajax but trying my best to understand. At this point I got a problem I'm not able to solve. I've looked on several forums and googled internet but I can't find a solution :S. This is the basic idea: I'm trying to implement Ajax in a Portal page created in weblogic 9.2. I've created a portlet with the name Ajax.jsp and an additional page called test.jsp. Ajax.jsp is the main portlet page. And uses the...
3
2590
by: Andrewh | last post by:
Hi, I am having a bit of a problem with using xmlhttp. The code of the javascript file is shown below used in Windows XP. var xmlhttp = null; function SetURLDiv(url) { if (window.XMLHttpRequest) {
21
3896
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support this property or method'. <form name="myform" action="main.asp" method="post"> <div id="content"> <h2 id="pageName">Main Page</h2> <div class="feature"> <h1>Surfing the intranet </h1> <p> This is a comprehensive information...
2
12469
by: trpost | last post by:
Is it possible to execute javascript as passed in xmlHttp.responseText Here is what I am doing: search.js var xmlHttp xmlHttp=GetXmlHttpObject() var url="search.php" xmlHttp.onreadystatechange=stateChanged
0
8884
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9400
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9252
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9168
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9103
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8084
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6700
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4779
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3217
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.