/    Sign up×
Community /Pin to ProfileBookmark

Issue with Ajax in Mozilla Firefox 3.0 and above

Hello All,

I am using Ajax method to read a html file and show the content in a div. I use ajax method to read the html file. What happens now is this works perfectly in IE(all versions) and Mozilla (2 and below) and but not in Mozilla 3 and above. Please help me to solve this. My code is given below.

When i give the last parameter as ‘false’, it works for IE and not for Mozilla 3 and above.
On the other hand when i give ‘true’ for the parameter it works in Mozilla 3.o and not in IE. My website is targetted for both IE and Mozilla users.

To fix this i declared a varaibale, check the browser set it to true on Mozila and false on IE. This worked well for both browsers when i was having an alert to show the param value. When i removed it it stopped for Mozilla and only works on iE.

Code:
—–

var param;

if(navigator.appName.indexOf(“Microsoft Internet Explorer”) == 0)
{
param= false;
}

else
{

param= true;
}

if (window.XMLHttpRequest)
{ // code for Mozilla, Safari, ** And Now IE 7 **, etc
xmlhttp=new XMLHttpRequest();

if (xmlhttp.overrideMimeType) {

xmlhttp.overrideMimeType(‘text/html’);

}

} else if (window.ActiveXObject) { //IE

xmlhttp=new ActiveXObject(‘Microsoft.XMLHTTP’);

}

if (typeof(xmlhttp)==’object’) {

xmlhttp.open(‘GET’, ‘http://localhost/TMC/Content/EditDiv.htm’, param);

xmlhttp.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);

xmlhttp.onreadystatechange=CheckFilereadyState;

xmlhttp.send(null);

}

Any help will be appreciated

Regards,
Anand

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@budsterOct 23.2008 — Hi Anand,

This example works in firefox 3 (it displays the html file as an alert but that could easily be changed).

http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11340

Hope this helps
Copy linkTweet thisAlerts:
@A1ien51Oct 23.2008 — Why are you setting the async flag to true for only IE? Makes no sense.

Eric
×

Success!

Help @anandav200 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...