473,725 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE AJAX Issue..

Hello all,

I have run across an issue with IE 6.0+. I have a page that makes an
XMLHttpRequest to the webserver to update a report on the page. The
first time you hit the refresh report button the data is refreshed,
however if you try to refresh the report the onreadystatecha ge does
not seem to fire. I have tested this by placing an alert in the
verifyID2 & verifyID3 function to track where the XMLHttpRequest
currently is. Now when creating the Javascript i tend to lean towards
FireFox for obvious reasons. I have created similar Functions on other
pages that seem to work over multiple browsers so i am sort of
stumped.

Please let me know if you come up with anything. I have been looking
all over the place.

function verifyID(){
var ss = document.getEle mentById('repor tspan')
ss.innerHTML = '';
ss.innerHTML = '<img src=\"vistawait 2.gif\" alt=\"Please Wait
\">&nbsp;Prepar ing Reporting';
ss.style.cursor = 'wait';
setTimeout("ver ifyID2()",0);
}
function verifyID2(){
var ss = document.getEle mentById('repor tspan')
var varLoc = document.getEle mentById('locat ion').value;
var varSDate = document.getEle mentById('sdate ').value;
var varEDate = document.getEle mentById('edate ').value;
ss.style.cursor = 'wait';
var url = 'get_unass_xml. php?location='+ varLoc+'&sdate= '+varSDate
+'&edate='+varE Date+'&ses='+ Math.random()
if (searchReq.read yState == 4 || searchReq.ready State == 0) {
alert('Preparin g Send'); //added to verify we are about to send
data
searchReq.onrea dystatechange = verifyID3;
searchReq.open( 'GET', url, true);
searchReq.send( null);
}
}
function verifyID3(){
if(searchReq.re adyState != 4){
alert(searchReq .readyState); //added to watch ready states <-
Second run never displays this message.
return false;
}
var ss = document.getEle mentById('repor tspan')
var response = searchReq.respo nseText.split(" :");
if(response[0]=='true'){
document.getEle mentById('next' ).style.display = 'none';
ss.innerHTML = '<img src=\"vistawait 2.gif\" alt=\"Please
Wait\">&nbsp;Ge nerating View';
ss.style.cursor = 'default';
setTimeout("doN othing()",0)
if (searchReq.over rideMimeType){
searchReq.overr ideMimeType('te xt/xml');
}
ss.innerHTML = '<table id=\"responseta ble\"></table>';
setTimeout("doN othing()",300)
var tbl = document.getEle mentById('respo nsetable');
var row = tbl.insertRow(0 );
var cell = row.insertCell( 0);
cell.innerHTML = '<a href=\"javascri pt:verifyID();
\">refresh report</a>';
var row = tbl.insertRow(1 );
var cell = row.insertCell( 0);
cell.innerHTML = 'Unassigned ID\'s With Hours';
if (searchReq.read yState == 4 || searchReq.ready State ==
0) {
if (isBusy){
searchReq.abort ;
}
searchReq.open( 'GET', response[1], true);
searchReq.onrea dystatechange = verifyID4;
searchReq.send( null);
}

}
else{
ss.innerHTML = '<img src=\"check.gif \" alt=\"Check
\">&nbsp;No Unassigned ID\'s Please Contiue.';
document.getEle mentById('step' ).value = 1;
document.getEle mentById('s1td1 ').className = 'active';
document.getEle mentById('s1td2 ').className = 'active';
document.getEle mentById('next' ).value = 'Next';
var varLoc = document.getEle mentById('locat ion').value;
var varSDate = document.getEle mentById('sdate ').value;
var varEDate = document.getEle mentById('edate ').value;
setStep(varLoc, varSDate,varEDa te,'3');
}
}
function verifyID4(){
if (searchReq.read yState == 4) {
var varLoc = document.getEle mentById('locat ion').value;
var xmldoc = searchReq.respo nseXML;
var root = xmldoc.getEleme ntsByTagName('r oot').item(0);
for (var iNode = 0; iNode < root.childNodes .length; iNode+
+) {
var node = root.childNodes .item(iNode);
for (i = 0; i < node.childNodes .length; i++) {
var sibl = node.childNodes .item(i);
var len = parseInt(sibl.c hildNodes.lengt h / 2);
var arr = new Array(len);
var cnt = 0;
for (x = 0; x < sibl.childNodes .length; x++) {
var sibl2 = sibl.childNodes .item(x);
var sibl3;
if (sibl2.childNod es.length 0) {
sibl3 = sibl2.childNode s.item(0);
arr[cnt] = sibl3.data;
cnt++;
}
}
url = '<span style=\"cursor: pointer;\" onClick=
\"javascript:wi ndow.open(\'sho wEmpHours.php?l ocation='+varLo c
+'&employee='+a rr+'&sess='+Mat h.random()+'\', \'Hours_View\',
\'status=0,tool bar=0,scrollbar s=1,width=620,h eight=480\');\" >'+arr+'</
span>';
addrow("respons etable", url);
}
}
var ss = document.getEle mentById('repor tspan')
document.getEle mentById('s1td1 ').className = 'error';
document.getEle mentById('s1td2 ').className = 'error';
}
}

Thank you in Advance....

Apr 11 '07 #1
6 2540
On 10 abr, 17:18, "Nico VanHaaster" <nvanhaas...@ca itele.comwrote:
Hello all,

I have run across an issue with IE 6.0+. I have a page that makes an
XMLHttpRequest to the webserver to update a report on the page. The
first time you hit the refresh report button the data is refreshed,
however if you try to refresh the report the onreadystatecha ge does
not seem to fire. I have tested this by placing an alert in the
verifyID2 & verifyID3 function to track where the XMLHttpRequest
currently is. Now when creating the Javascript i tend to lean towards
FireFox for obvious reasons. I have created similar Functions on other
pages that seem to work over multiple browsers so i am sort of
stumped.

Please let me know if you come up with anything. I have been looking
all over the place.

function verifyID(){
var ss = document.getEle mentById('repor tspan')
ss.innerHTML = '';
ss.innerHTML = '<img src=\"vistawait 2.gif\" alt=\"Please Wait
\">&nbsp;Prepar ing Reporting';
ss.style.cursor = 'wait';
setTimeout("ver ifyID2()",0);}
Why use the setTimeout() call above? Why not just merge verifyID() and
verifyID2() or just call verifyID2() directly above?
function verifyID2(){
var ss = document.getEle mentById('repor tspan')
var varLoc = document.getEle mentById('locat ion').value;
var varSDate = document.getEle mentById('sdate ').value;
var varEDate = document.getEle mentById('edate ').value;
ss.style.cursor = 'wait';
var url = 'get_unass_xml. php?location='+ varLoc+'&sdate= '+varSDate
+'&edate='+varE Date+'&ses='+ Math.random()
if (searchReq.read yState == 4 || searchReq.ready State == 0) {
searchReq just magically appeared here. When was it instantiated? Why
do you need to test it's ready state before you send the request?
alert('Preparin g Send'); //added to verify we are about to send
data
searchReq.onrea dystatechange = verifyID3;
searchReq.open( 'GET', url, true);
searchReq.send( null);
}}

function verifyID3(){
if(searchReq.re adyState != 4){
It looks like searchRequest is some sort of global. What happens if
two XHR requests are simultaneous. Will searchRequest point to the
second request? What happens when the first XHR (likely) returns first
and calls verifyID3()? It will try to look at the readyState of the
second request which is not 4 yet.
alert(searchReq .readyState); //added to watch ready states <-
Second run never displays this message.
return false;
}
var ss = document.getEle mentById('repor tspan')
var response = searchReq.respo nseText.split(" :");
if(response[0]=='true'){
document.getEle mentById('next' ).style.display = 'none';
ss.innerHTML = '<img src=\"vistawait 2.gif\" alt=\"Please
Wait\">&nbsp;Ge nerating View';
ss.style.cursor = 'default';
setTimeout("doN othing()",0)
if (searchReq.over rideMimeType){
searchReq.overr ideMimeType('te xt/xml');
}
ss.innerHTML = '<table id=\"responseta ble\"></table>';
setTimeout("doN othing()",300)
var tbl = document.getEle mentById('respo nsetable');
var row = tbl.insertRow(0 );
var cell = row.insertCell( 0);
cell.innerHTML = '<a href=\"javascri pt:verifyID();
\">refresh report</a>';
var row = tbl.insertRow(1 );
var cell = row.insertCell( 0);
cell.innerHTML = 'Unassigned ID\'s With Hours';
For a posting where you are seeking help I think a lot of the above
could have been trimmed to just and alert() call.

if (searchReq.read yState == 4 || searchReq.ready State ==
0) {
if (isBusy){
searchReq.abort ;
}
searchReq.open( 'GET', response[1], true);
searchReq.onrea dystatechange = verifyID4;
searchReq.send( null);
I remember reading on quirksmode.com that reusing an XHR object can
cause problems. I don't reuse XHR objects so haven't had to look into
this.
}

}
else{
ss.innerHTML = '<img src=\"check.gif \" alt=\"Check
\">&nbsp;No Unassigned ID\'s Please Contiue.';
document.getEle mentById('step' ).value = 1;
document.getEle mentById('s1td1 ').className = 'active';
document.getEle mentById('s1td2 ').className = 'active';
document.getEle mentById('next' ).value = 'Next';
var varLoc = document.getEle mentById('locat ion').value;
var varSDate = document.getEle mentById('sdate ').value;
var varEDate = document.getEle mentById('edate ').value;
setStep(varLoc, varSDate,varEDa te,'3');
}}

function verifyID4(){
if (searchReq.read yState == 4) {
var varLoc = document.getEle mentById('locat ion').value;
var xmldoc = searchReq.respo nseXML;
var root = xmldoc.getEleme ntsByTagName('r oot').item(0);
for (var iNode = 0; iNode < root.childNodes .length; iNode+
+) {
var node = root.childNodes .item(iNode);
for (i = 0; i < node.childNodes .length; i++) {
var sibl = node.childNodes .item(i);
var len = parseInt(sibl.c hildNodes.lengt h / 2);
var arr = new Array(len);
var cnt = 0;
for (x = 0; x < sibl.childNodes .length; x++) {
var sibl2 = sibl.childNodes .item(x);
var sibl3;
if (sibl2.childNod es.length 0) {
sibl3 = sibl2.childNode s.item(0);
arr[cnt] = sibl3.data;
cnt++;
}
}
url = '<span style=\"cursor: pointer;\" onClick=
\"javascript:wi ndow.open(\'sho wEmpHours.php?l ocation='+varLo c
+'&employee='+a rr+'&sess='+Mat h.random()+'\', \'Hours_View\',
\'status=0,tool bar=0,scrollbar s=1,width=620,h eight=480\');\" >'+arr+'</
span>';
addrow("respons etable", url);
}
}
var ss = document.getEle mentById('repor tspan')
document.getEle mentById('s1td1 ').className = 'error';
document.getEle mentById('s1td2 ').className = 'error';
}

}
Have you thought about extracting the XHR part of the above into an
Ajax library for reuse like Yahoo! UI or something similar? Or maybe
just using one of the many existing Ajax libraries?

Please try to trim example code as much as possible to get the best
response.

Good luck.

Peter

Apr 11 '07 #2
"Peter Michaux" <pe**********@g mail.comwrote in message
news:11******** **************@ b75g2000hsg.goo glegroups.com.. .
On 10 abr, 17:18, "Nico VanHaaster" <nvanhaas...@ca itele.comwrote:
>Hello all,
I remember reading on quirksmode.com that reusing an XHR object can
cause problems. I don't reuse XHR objects so haven't had to look into
this.
Hello, Mr. Michaux. Are you sure you read that correctly?

http://www.quirksmode.org/js/xmlhttp.html

Koch specifically states that in a given scenario where the requests are limited to three
to five files, creating new XMLHttpRequest objects is fine. However, this makes no sense
in an instance that requires several hundred or more requests. Reusing the object reduces
overhead.

Of course he eludes to the fact that an XMLHttpRequest should manage its requests, however
many of them there may be.

-Lost
Apr 11 '07 #3
Thank you Both for your help.

I was able to find a few resources that point to creating a global
variable to set to true\false based on the XHR's state. In IE you need
to check the status of the XHR when calling additional requests on the
same object. And using the XHR.abort() function.

See here for an idea of what i am talking about.

http://www.robertnyman.com/2007/04/0...-call-allowed/

Apr 11 '07 #4
On Apr 11, 12:42 pm, "Nico VanHaaster" <nvanhaas...@ca itele.com>
wrote:
Thank you Both for your help.

I was able to find a few resources that point to creating a global
variable to set to true\false based on the XHR's state. In IE you need
to check the status of the XHR when calling additional requests on the
same object. And using the XHR.abort() function.

See here for an idea of what i am talking about.

http://www.robertnyman.com/2007/04/0...est-error-in-i...
Another issue you may need to consider is that IE will cache GET
requests. Therefore if it finds that a previous request with the exact
same URL was already made, it will use the cached results from that
request and display it, rather than sencind a new request. You can
override this functionality by assigning a random value to the end of
your url for each request (i.e. the current time in milliseconds or
something like that).

Apr 12 '07 #5
"Tom Cole" <tc****@gmail.c omwrote in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
On Apr 11, 12:42 pm, "Nico VanHaaster" <nvanhaas...@ca itele.com>
wrote:
>Thank you Both for your help.

I was able to find a few resources that point to creating a global
variable to set to true\false based on the XHR's state. In IE you need
to check the status of the XHR when calling additional requests on the
same object. And using the XHR.abort() function.

See here for an idea of what i am talking about.

http://www.robertnyman.com/2007/04/0...est-error-in-i...

Another issue you may need to consider is that IE will cache GET
requests. Therefore if it finds that a previous request with the exact
same URL was already made, it will use the cached results from that
request and display it, rather than sencind a new request. You can
override this functionality by assigning a random value to the end of
your url for each request (i.e. the current time in milliseconds or
something like that).
http://jibbering.com/faq/#FAQ4_17

-Lost
Apr 12 '07 #6
On my querystrings i add ...&sess='+Math .random()+'... to make sure it
isn't a caches url.

That should do it.

Apr 14 '07 #7

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

Similar topics

4
4326
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 from within an inline function. Within the AJAX object: this.xmlhttp = new XMLHttpRequest(); this.response = ''; //to contain the response text OR xml var that = this; //since we cannot reference this within the
4
7709
by: ext237 | last post by:
Simple ajax call seems to have some issues in Firefox. The "onComplete:" is called BEFORE the response is returned by the call. Is there a coding issue or a work around? var ajax = new Ajax.Request( url, {method: 'post', parameters: params, onComplete: evalInfo }); function evalInfo( request ) { // do stuff with request
2
2134
by: verci | last post by:
Hi guys, I'm running VS2005, AP.net 2.0, Windows XP SP2 Ok this maybe a dumb question but here it goes, as a newbie I've just finished my first AJAX enable page, everything works great but, until I press the back and forward buttons in my browser then the AJAX magic is lost alongside with all the data in my AJAX controls when I tried to get back to the AJAX page, can anybody help me solve this issue, I've read that this is the...
17
11881
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);" onclick="show('ajaxrequest.php?action=removefield','div1');show('ajaxrequest.php?action=reloaddiv2','div2')">verwijderen</a> While both seperate actions work they dont when I put them together. Anyone know how to fix this ? My ajax.js with funcition show
7
2809
by: =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?= | last post by:
Hi! I know this topic has been discussed a long way, but I haven't found any apparent solution (maybe I shouldn't be looking for a one :)) I have a very simple application with one page and with just ScriptManager object in it. Every time I refresh the page the memory usage goes up. I have AJAX extenstions 1.0 installed and IE7 on winxp. Is this IE or AJAX problem, and how did you guys cope with this problem? Please reply asap... i am...
10
3154
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e. every 5 seconds, i just want to refresh it ONLY on server change just like desktop applications do. The problem is that refreshing evry n seconds has to much impact on my web server. The refresh action should be taken only when something
10
3474
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario ------------- I have perl script which simply runs a ps on a Solaris server and generates a static html page with all of the code perfectly and this html page works fine when viewing it statically or with a META REFRESH header tag. The idea is to give the user...
5
3105
by: simon | last post by:
hello, I have a server set up on my local (home) network and can not get an ajax application to run on the box. it works fine on our developement server and also works fine locally. I copied the application to the server, setup the website, installed the ajax extensions, also loaded/enabled front end extensions so i could load the site in visual studio 2005. when i attempt to run the site, either from the server or from another pc...
6
2637
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered in the page and I've got code to get the selected value from it in the Radiobuttonlist_SelectedIndexChanged event. The code in there is: Protected Sub rblFMSValue_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
11
3036
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7 and IE8. There is no issue when the controls are allowed to complete loading. Can you please tell me the best practice that handles this? Thanks.
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9113
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.