File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Problem with AJAX in FireFox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problem with AJAX in FireFox " Watch "Problem with AJAX in FireFox " New topic
Author

Problem with AJAX in FireFox

Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
This is happening only in FireFox, IE is working fine with the same code.

After getting xmlHttpRequest object, in callback method Iam checking as

if(xmlHttp.readyState==4){

tr{
if(xmlHttp.state==200){// this line failed to execute
//and thowing 'Undefined exception
//Do something
}
}catch(e){alert(e.description);}
}

I dont understand why it is happening after getting readyState=4
Any help apprecialted.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I think you need to relook at the properties of the XMLHttpRequest Object: http://en.wikipedia.org/wiki/XMLHttpRequest#Properties

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

"infant papa",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by infant papa:

if(xmlHttp.state==200){// this line failed to execute
//and thowing 'Undefined exception
//Do something


status is the property of XMLhttpRequest is used to check the status of page I didn't found any property/method with the name of state to checking status of the page..

Originally posted by infant papa:
This is happening only in FireFox, IE is working fine with the same code.


Eric, can you tell me how it's working on IE with the wrong property..
"Is IE parser is Integellent to understand the user requirements.."

Thanks,
[ October 05, 2006: Message edited by: Saif Uddin ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
Sorry for the mistake, here is the code

function processCallBack()
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)// Throwing exception
{
var content = xmlHttp.getResponseHeader("Content-Type");
if(content == 'text/plain')
{
var xmlResponseMessage = xmlHttp.responseText;
handleResponse(xmlResponseMessage);
}
}
}
}
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
Some where in the blogs I found it is a bug in FireFox versions which is not yet fixed, But I dont agree with that, I have done some small examples long back and they were working fine with Firefox also,

Here after getting response from Server, the xmlHttp object is throwing exception when we try to access status property. Same code is working fine with IE.

Please help me, I stuck with this from last 3 days...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

How did you get xmlHttp ?

(Please do not ignore Bear's message about the naming policy)


[My Blog]
All roads lead to JavaRanch
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
Hi Satou,

Here is how I got xmlHttp object

function getXmlHttpObject() {

if(window.XMLHttpRequest) {
try {
xmlHttpRequest = new XMLHttpRequest();
isMozilla = true;
} catch(e) {
return null;
}
} else if(window.ActiveXObject) {
try {
xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
return null;
}
}
} else return null;
return xmlHttpRequest;
}
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

About the exception you've got, where is it displayed ? Can you post the full message ?
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
This is the error message Iam getting in FireBug.

[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://localhost:9080/hr/europe/aboutyou/wizards.js :: processCallBack :: line 342" data: no]


I have seen some of the topics given by Eric regarding this problem, but it wont solve my problem.

As he suggests

var status = "";
try{
status = yourXHRVariable.statusText;
}
catch(e){
status = "Trouble accessing it";
}

So it always shows status as "Trouble accessing it" in FireFox but works fine in IE.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I'm not sure this would help but try with :
if (xmlHttp.status == 200 || xmlHttp.status == 0)
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
It didn't help me

Let me explain what Iam doing exactly..

I have a text box which is readonly and have a button next to it which popups a window to choose a link(Names). It(child window) automatically closes and populates Text box with Name which we selected.

Iam firing ajax code on onChange,onpropertychange event of text box.

1. Firing the xmlHttp request
2. Not showing any response or Header information
3. It shows folloing exception in FireBug console (while populating name into textbox)

[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://localhost:9080/

4. After not getting any response at all.
5. some times Iam getting response by clicking on textbox with mouse (when text box gets focus)

is the problem with events or child window or browser compatibility ?? I dont understand.. Same code working in IE fine
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

http://radio.javaranch.com/pascarello/2006/02/07/1139345471027.html
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
Still the problem persists!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with AJAX in FireFox