Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with AJAX in FireFox

 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you get xmlHttp ?

(Please do not ignore Bear's message about the naming policy)
 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About the exception you've got, where is it displayed ? Can you post the full message ?
 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure this would help but try with :
if (xmlHttp.status == 200 || xmlHttp.status == 0)
 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still the problem persists!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic