473,407 Members | 2,598 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,407 software developers and data experts.

"Object Required" by IE 6 when using Msxml2.XMLHTTP

This AJAX stuff is all new to me. To try it out, I borrowed this code
from a website:

========================

var http_request = false;
function makeRequest(url) {

http_request = false;

if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');

}
}
else if (window.ActiveXObject)
{ // IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
//Failure on above line!
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
}
}
}
=======================

In Firefox and Safari, I'm having great success. In IE 6, I get an
"Object Required" failure while trying to run this line:

http_request = new ActiveXObject("Msxml2.XMLHTTP");

I guess I'm missing something pretty basic. Can someone point me in the
right direction?
Thanks!

--Brent
Nov 23 '05 #1
5 3759
You will hate it, but I cut & paste your code and it works without
error in IE6... this is what I copied from Google:

function connect() {
var C=null;
try {
C=new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e) {
try{
C=new ActiveXObject("Microsoft.XMLHTTP")
}
catch(sc) {
C=null
}
}
if(!C && typeof XMLHttpRequest!="undefined") {
C=new XMLHttpRequest()
}
return C;
}

but it looks like your code :( I don't see anything wrong in your code
except that you set http_request to false twice (i would set it to
"null" to start with), and you don't return it. Try my code see if it
works!

Nov 23 '05 #2
Yes, your code works fine. With the addition of the open() and send()
methods (and a closing brace for your function), I get a positive
response. Could you post the rest of your code?

Nov 23 '05 #3
Thanks for your replies! The entire code <script> to </script> is
attached. I haven't made any changes overnight...and it's still not
working! ;=)

================================================== =================

<script type="text/javascript" language="javascript">

var http_request = null;

function makeRequest(url) {

if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
// See note below about this line
}
}
else if (window.ActiveXObject)
{ // IE
try
{
if (!http_request)
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
}
}
}

if (!http_request)
{
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('GET', url, true);
http_request.send(null);

}

function alertContents() {

if (http_request.readyState == 4) {
if (http_request.status == 200) {

var xmldoc = http_request.responseXML;
var divid_node = xmldoc.getElementsByTagName('divid').item(0);
var id = document.getElementById(divid_node.firstChild.data );

var data_node = xmldoc.getElementsByTagName("data");
var outText = "";

for (i=0;i<data_node.length;i++)
{
var thisitem = data_node[i];
var sid =
thisitem.getElementsByTagName("gics_code").item(0) .firstChild.data;
var thiscount =
thisitem.getElementsByTagName("count").item(0).fir stChild.data;

outText += '<div><a href="sector.aspx?sid='+ sid +'">' +
thisitem.getElementsByTagName("gicdesc").item(0).f irstChild.data + '
('+thiscount+')</a></div>';
}
id.innerHTML = outText;
} else {
alert('There was a problem with the request.');
}
}

}

function ShowHide(divId)
{
var id = document.getElementById(divId);
id.style.display = ('none' == id.style.display)? '':'none';
}

</script>
Nov 23 '05 #4
Brent <"writeBrent at the google mail place"> wrote:

In Firefox and Safari, I'm having great success. In IE 6, I get an
"Object Required" failure while trying to run this line:

http_request = new ActiveXObject("Msxml2.XMLHTTP");


I believe that this line assumes that an ActiveX server names "Msxml2"
is installed and properly registered on your computer. Are you sure
that this has been done?

--
Tim Slattery
Sl********@bls.gov
Nov 23 '05 #5
So...I figured it out...it turns out that the problem wasn't the object
I thought, but rather that the response coming back into the
makeRequest function wasn't coded as XML. Safari and Firefox had no
problem with it because of the line ...

http_request.overrideMimeType('text/xml');

....but IE Explorer wasn't so forgiving. I changed the response type to
"text/xml" server side, and all's well.

Or not quite well: now, in IE Explorer, the code runs once and once
only. I have to reload the page to get it to run again.

It'd be nice to have some pointers on this issue, too!

Thanks for all your replies!

--Brent

Brent wrote:
This AJAX stuff is all new to me. To try it out, I borrowed this code
from a website:

Nov 23 '05 #6

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

Similar topics

2
by: Dave Hammond | last post by:
I've got what should be a simple assignment of either an element value or a default string to a variable, but when the element doesn't exist I get an "Object required" error rather than an...
11
by: Florian Loitsch | last post by:
I'm currently writing a JS->Scheme compiler (which, using Bigloo, automatically yields a JS->C, JS->JVM, JS->.NET compiler), and have a question concerning the function-parameters: According to...
3
by: Steve Lutz | last post by:
Hi All, I have a Windows Service that runs well. The service hosts a remote object. The purpose of the object is so that I can "peak" into the service to see what it's doing. I wrote a small...
3
by: Karel Vandenhove | last post by:
Hi, I get an error "cannot apply indexing with to an expression of type object" when I try to compile the code below. SSLScannerManager is a COM component. (Used to access fingerprint...
1
by: Jens Øster | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send...
5
by: Christian Hvid | last post by:
What is the easiest way to get the "row object" or "item object" when a datagrid is clicked? I have web form with a datagrid. And I have an array of something called BlogEntry that I bind to the...
2
by: =?Utf-8?B?QmFkaXM=?= | last post by:
I'm doing a server side automation(I know it's bad but..) and its working fine locally and when accessing it from a remote machine using web browser is was giving me this error"Retrieving the COM...
3
by: =?Utf-8?B?QmFkaXM=?= | last post by:
I'm doing a server side automation(I know it's bad but..) and its working fine locally and when accessing it from a remote machine using web browser is was giving me this error"Retrieving the COM...
2
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%=...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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 projectplanning, 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.