473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

AJAX IE using Firefox XMLHttpRequest()

My code is as follows.

http_request = false;
if (window.XMLHttpRequest) {
alert("firefox");
http_request = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
alert("ie");
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.open('GET', url + parameters, true);
http_request.onreadystatechange = alertContents;
http_request.send(null);
}

Now I was under the impression that IE didnt have support for
XMLHttpRequest like firefox so thought you had to do it this way. But
this code works in firefox and alert says firefox. however code doesnt
work in IE and prints firefox in alert
Dec 19 '07 #1
1 1744
Iain Adams wrote:
>
Now I was under the impression that IE didnt have support for
XMLHttpRequest like firefox so thought you had to do it this way. But
this code works in firefox and alert says firefox. however code doesnt
work in IE and prints firefox in alert
IE 7 supports XMLHttpRequest so your check
if (window.XMLHttpRequest)
yields true with Mozilla, with Opera 8 and later, with IE 7, with Safari
(I think 1.2 and later).
Feature check like the above are fine, only you should not use them to
infer a certain browser. All you can infer is that
boolean(window.XMLHttpRequest) evaluates to true.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 19 '07 #2

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

Similar topics

5
by: Danny R | last post by:
I have the following javascript which works in either IE or Firefox but not on both. When I set the code to http_request.open('POST', url, true) - Works in IE only http_request.open('GET',...
3
by: Erik Cruz | last post by:
Hi. I will start to migrate an asp.net 1.1 application to 2.0. This application uses an Iframe that simply calls a method to update a field on my databse every minute. In order to do this, I...
1
by: diaboliko80 | last post by:
Salve a tutti. Ho un problema con IE7. Ho implementato una pagina .asp che tramite tecnologia AJAX mi crea una serie di select nidificate (il classico esempio delle Regioni-Province --scelgo...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
0
by: Tarik Monem | last post by:
I have been working on an all AJAX/DOM web site which is set to go live today and I thought I'd share my discoveries with all of you whom have helped me when I have encountered different issues along...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
2
by: rpollard | last post by:
Hi, I am relatively new to Ajax and am wondering if someone can shed a bit of light on the conceptual part of how Ajax handles its communication. Not knowing a whole lot about Ajax when I...
1
by: bizt | last post by:
Hi, I am having my first real attempt at an ajax class as so far Ive managed to build one that, once instatiated, will allow me to define which function it will call on completion then retrieves...
3
by: George | last post by:
I am doing an AJAX call using JQuery on my page to which returns JSON objects and everything works fine. Now I decided to use ashx handler instead of and simply write JSON out. Then my problems...
7
by: mike57 | last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...

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.