IE Ajax Request Confusion

P

PaPa

function getpage(pagename)
{
var request="";

This code worked fine in Mozilla, but caused an error in IE7. I have
no tools to discover what the error was.
////////////////////////////////////////////////////////////////////////////////////
try{
request=new XMLHttpRequest();
}
catch(e){
try{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
request= new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
alert('sorry, your browser will not suport this
presentation');
}
}
}

var pn=pagename+".htm";
request.open("GET",pn);
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\

When I swapped the order of the requests, the code worked fine in both
Mozilla and IE7.

///////////////////////////////////////////////////////////////////////
function getpage(pagename)
{
var request="";

try{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
request=new XMLHttpRequest();
}
catch(e){
try{
request= new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
alert('sorry, your browser will not suport this
presentation');
}
}
}

var pn=pagename+".htm";
request.open("GET",pn);
/////////////////////////////////////////////////////////////////////////////////////////////////

Am I missing something obvious?

Regards,
PaPa
 
G

GArlington

function getpage(pagename)
{
var request="";

This code worked fine in Mozilla, but caused an error in IE7. I have
no tools to discover what the error was.
<snap>
Fiddler2 (for IE) is very similar to Firebug (for FF)...
For debugging you have a wonderful tool called "editor" => add some
alert statements to your catch clauses and output exception details...
 
D

Dr J R Stockton

In comp.lang.javascript message <a11f1c52-e6b4-4d5a-a7ae-046014045ab0@a1
g2000hsb.googlegroups.com>, Fri, 8 Aug 2008 04:56:42, PaPa
function getpage(pagename)
{
var request="";

This code worked fine in Mozilla, but caused an error in IE7. I have
no tools to discover what the error was.
///////////////////////////////////////////////////////////////////////
Am I missing something obvious?

Yes.

The need to state the exact error message and to indicate which line if
any it referred to.

The need to reduce your tab indents to two-space indents and make the
lines of reasonable length for News.

A use of the Shift key.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top