×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Delay with AJAX request

Delay with AJAX request

Delay with AJAX request

(OP)
Hi,

I have a page (written in ASP) that displays a series of titles.  When you click a title it unhides a div and then makes an AJAX request to look up more information about that particular title and then displays it in the div.

For some reason when I click the link there is quite a long pause (about 4 seconds on average) before it displays the text but on the other hand if I run the ASP on it's own eg showcsritem.asp?CSRPostID=5 it displays almost immediately.

Has anyone ever come across this sort of problem before?

Thanks

Ed
Replies continue below

Recommended for you

RE: Delay with AJAX request

Hello,

Could you post your AJAX code? There is a possiblity that your script uses the javascript setTimeout function and has been set to around 4000 milliseconds, which needs to be lowered.

Chris

RE: Delay with AJAX request

(OP)
Here's the code

CODE

var xmlhttp

function showItem(CSRPostID)
{
if (CSRPostID.length==0)
  {
  document.getElementById("mypopup2").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="showcsritem.asp";
url=url+"?CSRPostID="+CSRPostID;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("mypopup2").innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

It's the same code I've used elsewhere and not had any performance issues - if need be I can post the other scripts; there are hidden divs and server side includes and stuff which might complicate things slightly but at the moment it's a real puzzler!

Thanks

Ed

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close