Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 12-17-2007, 05:52 AM IE error message
Experienced Talker

Posts: 30
Trades: 0
Hi all,
I found a little script on the internet to load only a part of a page.
Now it uses javascript but it doesn't work in IE, firefox works fine and so does Opera, but IE doesn't (as always).
The Javascript code I use is the next:
Code:
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject(”Msxml2.XMLHTTP”);
} catch (e) {
try {
xmlhttp = new ActiveXObject(”Microsoft.XMLHTTP”);
} catch (E) {
xmlhttp = false;
}
}
@end @*/

// branch for native XMLHttpRequest object (Mozilla & Safari)
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
//return xmlhttp;

/*
if (!xmlhttp && typeof XMLHttpRequest!=’undefined’) {
xmlhttp = new XMLHttpRequest();
} */

function calc_py(fragment_url, element_id) {
var element = document.getElementById(element_id);
element.innerHTML = "Loading …";
xmlhttp.open("GET", fragment_url+'?a=1', true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
element.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
Now, IE gives an error line 8 ("xmlhttp = new...."), can anyone, tell me whats wrong for IE with this script I found?

Thanks,
klaroen
klaroen is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-17-2007, 06:44 AM Re: IE error message
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Which "("xmlhttp = new....")," ?

there are quite a few

But then again the problem may well be that the lines that are meant for IE to see and initialise the XML object are commented out.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-17-2007, 08:38 AM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
The one at line 8 .
I don't know that much about JS, but I shall give it a go uncommented

EDIT: I have tried it uncommented, but then both firefox and IE don't work.

Last edited by klaroen; 12-17-2007 at 08:41 AM..
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 09:41 AM Re: IE error message
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Right!

and line 8 would happen to be???
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-17-2007, 10:12 AM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
HTML Code:
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject(”Msxml2.XMLHTTP”);
} catch (e) {
try {
xmlhttp = new ActiveXObject(”Microsoft.XMLHTTP”);
} catch (E) {
xmlhttp = false;
}
}
@end @*/
Line ° 8 as, shown above and earlier is my posts.
"xmlhttp = new ActiveXObject(”Microsoft.XMLHTTP”);"
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 10:49 AM Re: IE error message
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,935
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Your E is capitalized in the line following. That's probably your issue.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-17-2007, 10:59 AM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
Code:
There was a runtime-error.

Line:9
Error:Object is expected
PHP Code:
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (E) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/ 
Hmm, line 9 ...

Last edited by klaroen; 12-17-2007 at 11:00 AM..
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 11:01 AM Re: IE error message
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,935
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
You misunderstood me. catch (e) should be a lowercase e. My bad.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-17-2007, 11:05 AM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
ok, changed it to lowercases, I don't get an error pupop nomore, but the refresh still won't work.. firefox does...

edit: This is the site where I got the original script: http://www.xuanau.com/2005/10/16/how...with-examples/

Ofcource changed a lot....

Last edited by klaroen; 12-17-2007 at 11:07 AM..
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 11:13 AM Re: IE error message
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,935
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Wow, I can barely read that. I don't know what font that guy's using, but that's hideous.

klaroen, you just learned a very important lesson here: be very careful with the scripts you use/find online. They're quite often buggy and useless (as the example above illustrates). It's best to take what's online with a grain of salt, try it, deconstruct it, destroy it, get pissed off with it, and put it back together in a way that you understand so that you can best learn from it.

Can you link to what you've done now, and maybe we can go from there?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-17-2007, 11:26 AM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
http://www.klaswebsite.be/risk/layout/games.php

Here you see a list of games out of a database, if you click Refresh only the table should refresh. Firefox does this, IE doesn't.
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 12:11 PM Re: IE error message
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Your code seems to be a mish-mash of various bits of code.
This is what your remote call function should look like;
Code:
function calc_py (fragment_url, element_id) {
var element = document.getElementById(element_id);
var xmlHttp;
try
  {
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("XMLHttp Request Object initialise failed");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	element.innerHTML = xmlHttp.responseText;
      }
    }
	xmlHttp.open("GET", fragment_url, true);
  xmlHttp.send(null);
  }
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-17-2007, 02:08 PM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
Hmm, none of the browsers work with that code...

EDIT: I've noticed something important: If you open the page with IE, for the first time since you opened the browser, it is able to refresh the table one!! if you click refresh again after that, it doesn't... This can help no?

Last edited by klaroen; 12-17-2007 at 02:14 PM..
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 02:41 PM Re: IE error message
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.candsdesign.co.uk/articles/code/ajax/test/

Works for me in all my Windows browsers (FF2, IE6, NS7, Moz1.7) didn't work in Opera 7.54 which isn't that surprising seeing as XMLHttpRequest support wasn't added until ver 7.60
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-17-2007, 04:26 PM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
I have changed it to your script, and you can try it at the lni kI gave above, but it doesn't work for me...
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 04:41 PM Re: IE error message
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Explain how it doesn't work.

BTW
name'btnJoin' isn't valid code.

and using single quotes is not valid for XHTML either they MUST be double quotes
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-17-2007, 04:47 PM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
Well, I click the refresh button, but it does nothing... does it with you?
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 04:59 PM Re: IE error message
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
What would you expect it to do? should it load something different?

If you want to test it, load up the page, make a change to the script it is loading from then click refresh. You should see your changes appear.

One other point, you have no form surrounding the inputs so your "Join Game" submit button will do nothing. And bear in mind that if and when you do add a form, your refresh button will submit the form as well as calling the AJAX function.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-17-2007, 05:16 PM Re: IE error message
Experienced Talker

Posts: 30
Trades: 0
Now, the last script had that "Loading..." thing in it, and because I didn't see the table minimize I thought it just didn't do anything, but it does reload.
Now (again) with IE, there is something weird.
I made a change to the table, upload it, refresh the whole page and the adjustment is shown. But when I click refresh button, it goes back to the state of before the adjustments... is it in cache or so?

And about those forms, the whole page isn't done yet, I am only worring about the reload yet, the rest will be simple.
klaroen is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to IE error message
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.54000 seconds with 12 queries