473,503 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX and IE problem

Am trying to set up a very simple AJAX script for my website. The
javascript i have in an external file which reads as below.

This works perfectly in firefox but IE doesn't display anything at all.
No error messages, just a blank IE window. If you look at the IE source
this html is all there it just won't show it!

Any ideas

// JavaScript Document

function GetXmlHttpObject(handler)
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
function getcounts(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="cgi-bin/countcomments.pl?blog_ids="
url=url+str
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
response = xmlHttp.responseXML.documentElement;
counts = response.getElementsByTagName('count');
for (i=0;i<=counts.length;i++)
{
id = response.getElementsByTagName('id')[i].firstChild.data;
num = response.getElementsByTagName('num')[i].firstChild.data;
idtofind = "commentcount" + id;
newhtml = " (" + num + ")";

document.getElementById(idtofind).innerHTML=newhtm l;
}

}
}

Oct 17 '06 #1
5 2764
Have half solved my problem. If i embed the javascript into the page it
works correctly.

Does IE have some security requirement about where external js files
are or something??

wi************@gmail.com wrote:
Am trying to set up a very simple AJAX script for my website. The
javascript i have in an external file which reads as below.

This works perfectly in firefox but IE doesn't display anything at all.
No error messages, just a blank IE window. If you look at the IE source
this html is all there it just won't show it!

Any ideas

// JavaScript Document

function GetXmlHttpObject(handler)
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
function getcounts(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="cgi-bin/countcomments.pl?blog_ids="
url=url+str
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
response = xmlHttp.responseXML.documentElement;
counts = response.getElementsByTagName('count');
for (i=0;i<=counts.length;i++)
{
id = response.getElementsByTagName('id')[i].firstChild.data;
num = response.getElementsByTagName('num')[i].firstChild.data;
idtofind = "commentcount" + id;
newhtml = " (" + num + ")";

document.getElementById(idtofind).innerHTML=newhtm l;
}

}
}
Oct 17 '06 #2
Hi,

wi************@gmail.com wrote:
Have half solved my problem. If i embed the javascript into the page it
works correctly.

Does IE have some security requirement about where external js files
are or something??
No, it should work also with external JavaScript. Your code looks OK on
first sight, except for one thing: IIRC, IE doesn't accept relative URLs
for XmlHttpRequest calls. Try with an absolute URL, and if it works, use
the Location object to create the absolute URL from the relative one.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 18 '06 #3
"Laurent Bugnion" <ga*********@bluewin.chskrev i melding
news:45**********@news.bluewin.ch...
Hi,

wi************@gmail.com wrote:
>Have half solved my problem. If i embed the javascript into the page it
works correctly.

Does IE have some security requirement about where external js files
are or something??

No, it should work also with external JavaScript. Your code looks OK on
first sight, except for one thing: IIRC, IE doesn't accept relative URLs
for XmlHttpRequest calls. Try with an absolute URL, and if it works, use
the Location object to create the absolute URL from the relative one.
Are you telling me that this production code for IE doesn't work?

var xmlReq;

function sendBid() {

var url = "submitBid.asp";
if (window.XMLHttpRequest) {
xmlReq = new XMLHttpRequest();
}
else {
xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
}

var buffer = "";
//filling buffer here...
...

xmlReq.open("POST", url, true);
xmlReq.onreadystatechange = xmlSendBidCallback;
xmlReq.setRequestHeader( "Content-Type",
"application/x-www-form-urlencoded");
xmlReq.send("bidData=" + escape(buffer));
}

Well, the url variable above points to a page _relative_ to the current
page,
and this piece of code have been working without a glitch for the last
12 months...

--
Dag.
Oct 18 '06 #4
Hi,

Dag Sunde wrote:
"Laurent Bugnion" <ga*********@bluewin.chskrev i melding
news:45**********@news.bluewin.ch...
>No, it should work also with external JavaScript. Your code looks OK on
first sight, except for one thing: IIRC, IE doesn't accept relative URLs
for XmlHttpRequest calls. Try with an absolute URL, and if it works, use
the Location object to create the absolute URL from the relative one.

Are you telling me that this production code for IE doesn't work?
<snip>
Well, the url variable above points to a page _relative_ to the current
page,
and this piece of code have been working without a glitch for the last
12 months...
Yes. I said IIRC, which means If I Recall Correctly. Seems that I
didn't, Sorry about that ;-)

I know that we had problems with relative URLs and web services in IE. I
can't remember why. It was 3 years ago...

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 20 '06 #5
VK
Yes. I said IIRC, which means If I Recall Correctly. Seems that I
didn't, Sorry about that ;-)

I know that we had problems with relative URLs and web services in IE. I
can't remember why. It was 3 years ago...
If we consider cross-domain lock for ajaxoids as a security mesure
(which is not and never was, but presuming if) then yes indeed
IXMLHTTPRequest / XMLHttpRequest do have this well-known "vulnerability
exploit" by allowing relative path in request. This is how one of the
most popular fixes ("mod_rewrite fix") is working: one calls say
"foobar.cgi" which is instructed in the server to be translated into
say "http://www.someAllAnotherServer.com/foobar.cgi".
Relative path was initially allowed on a number of send box
environments including for instance java.net.* package - and later
fixed to allow only fully-qualified path - for exactly the reason of
such exploits. So you may well be recalling a similar situation for
some another environment.
In application to ajaxoids the chances to have it "fixed" are very slim
though (too many of corporate solutions are running on it). And even if
"fixed" it adds nothing to the existing security, people will just
migrate on the second most popular (but more resource consuming)
alternative with server-side content grabbers. And the number zero :-)
stays as usual with iframe solutions.

Oct 20 '06 #6

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

Similar topics

4
4290
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but...
31
3073
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
5
2198
by: Martin | last post by:
Hello NG, I've been doing some AJAX for a few weeks now. The basics worked fine so far, but now I've got the following problem which I can't solve: With AJAX you typically update/replace only...
3
1669
by: Alok yadav | last post by:
I have an open IP and on that IP our main application is hosted. it uses ajax. in web.config file i have register ajax handlers. there are also other sites or project on that IP. now my problem is...
3
3116
by: equazcion | last post by:
Hi, I have an image reference (IMG) in my page that changes depending on the value of a database field. Clicking the image triggers an Ajax call to change the database field (toggles the field...
7
3148
by: tommurray | last post by:
Hi all Hope someone can help with the problem I am having as it is driving me nuts! I have the below script on my site the problem lies with passing through a url parameter in the below line...
6
5121
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
2
3125
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...
3
2448
by: willl69 | last post by:
Hi All, Ive been having a problem of late with one of my sites that uses PHP5 / Ajax. The problem is that periodically the ajax functions lock up and it gets stuck in the loading phase of the...
2
1648
by: majidtou | last post by:
Hi , We have an HTML page which is using AJAX. We make an AJAX call which retrieves a table with mutiple rows. We need to extend this functionality. In the table, we want to put a button on each...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
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,...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
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...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.