• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with AJAX in FireFox

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://radio.javaranch.com/pascarello/2006/02/07/1139345471027.html
 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still the problem persists!!
reply
    Bookmark Topic Watch Topic
  • New Topic