Erratic AJAX timeout errors
I inherited a system that uses AJAX to maintain a "crumb trail" dropdown list at the bottom of an iFrame. We get erratic, yet numerous AJAX timeout errors on a dynamically-created ashx file. The user's history is stored in a database table, which is used to populate the dropdown list's entries. We get this error many times in our production environment, but in our dev and staging environments not so much, mainly due, I suspect, to the difference in volume of users/transactions.
I've been coding Javascript and ASP/.NET for some time now, but my experience with AJAX and iFrames is practically nil. The implementation involves 3 functions - 2 Javascript and one ASP.NET/AJAX. The iFrame onload event calls the AJAX function (whose function is to update the entries in the dropdown list), passing the result of another javascript function (called _callback, whose function seems to be to rebuild/update the dropdown list).
The AJAX function pretty much just does a database read, but code snippets that may be relevant follow. I know I'm aiming at a pretty wide target here, but does anyone see anything that might be causing a timeout, or at least tell *which* point in the process is timing out? The strange thing is that it's not like you sit there for a long time waiting before the error occurs - it's amost instantaneous.
<iframe id="MainIFRame" name="MainIFRame"
src="<%= CurrentPageHTML %>" frameBorder="0" width="100%"
scrolling=auto height="<%= (GlobalVar1.ScreenHeight-200) %>px"
application="no" onload="IFrame_Load();">
</iframe>function IFrame_Load() {
MyApp.RC_Navigation.RefreshHT(_callback);
return true;function _callback(result) {
Thanks!
var jumpSelect = document.getElementById('jumpDDL');
for(var n=jumpSelect.length-1;n>=0;n--) {
jumpSelect.options.remove(n);
}
var activeIdx = 0;
var urlStr = "";
if(result.error!=null)
document.getElementById('NextBtn').innerHTML = result.error;
for(var i=0; i<result.value.Rows.length; i++) {
urlStr = result.value.Rows[i].PageUrl;
if(urlStr.indexOf("?")>=0)
urlStr += "&HT=" + result.value.Rows[i].OrderNo;
else
urlStr += "?HT=" + result.value.Rows[i].OrderNo;
jumpSelect.options[i] = new Option(result.value.Rows[i].PageTitle, urlStr);
if(result.value.Rows[i].Status=='Active') {
activeIdx = i;
jumpSelect.selectedIndex = i;
}
}
if(activeIdx > 0) {
urlStr = result.value.Rows[activeIdx-1].PageUrl;
if(urlStr.indexOf("?")>=0)
urlStr += "&HT=" + result.value.Rows[activeIdx-1].OrderNo;
else
urlStr += "?HT=" + result.value.Rows[activeIdx-1].OrderNo;
document.getElementById('PrevBtn').href = urlStr;
document.getElementById('PrevBtn').innerHTML = "<< " + result.value.Rows[activeIdx-1].PageTitle;
}
else {
document.getElementById('PrevBtn').innerHTML = '';
}
if(activeIdx < result.value.Rows.length - 1) {
urlStr = result.value.Rows[activeIdx+1].PageUrl;
if(urlStr.indexOf("?")>=0)
urlStr += "&HT=" + result.value.Rows[activeIdx+1].OrderNo;
else
urlStr += "?HT=" + result.value.Rows[activeIdx+1].OrderNo;
document.getElementById('NextBtn').href = urlStr;
document.getElementById('NextBtn').innerHTML = result.value.Rows[activeIdx+1].PageTitle + " >>";
}
else {
document.getElementById('NextBtn').innerHTML = '';
}
return true;
}
Answers
- Hi ,
In this scenario it is best to turn on Trace in WCF service end to investigate the reason for this question.
Also please have a look at this article about some common factors which will raise Timeout exception in client.
http://www.infosysblogs.com/microsoft/2009/06/troubleshooting_wcf_service_ap.html
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byRiquel_DongModeratorThursday, November 12, 2009 12:45 PM
All Replies
- Hi ,
In this scenario it is best to turn on Trace in WCF service end to investigate the reason for this question.
Also please have a look at this article about some common factors which will raise Timeout exception in client.
http://www.infosysblogs.com/microsoft/2009/06/troubleshooting_wcf_service_ap.html
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byRiquel_DongModeratorThursday, November 12, 2009 12:45 PM


