title: AJAX / ASP - Update Progress Panel - Response.Flush
body: <p>I am currently learning AJAX for the first time, mixed with Classic ASP.</p>
  
  <p>I have an AJAX script, that calls my ASP page (process.asp). In the ASP file is a simple loop between 1 and 1000, which is portraying an image process that I have elsewhere in my site, which I would like to add AJAX to later.</p>
  
  <p><strong>AJAX SCRIPT</strong></p>
  
  <pre><code>function processItems()
  {
  var xmlhttp;
  if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
  else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
  {
  document.getElementById("notification").innerHTML=xmlhttp.responseText;
  }
  }
  xmlhttp.open("GET","processItems.asp",true);
  xmlhttp.send();
  }
  </code></pre>
  
  <p><strong>ASP PAGE</strong></p>
  
  <pre><code>Response.Expires = -1
  i = 0
  Do Until i = 1000
  i = i + 1
  Loop
  Response.Write "Process complete"
  </code></pre>
  
  <p>At the moment it works fine, when the process has finished it writes a message to the user "process complete"... but, because there are lots of items to process, I would like to inform my user which item is currently getting processed e.g. "processing item 17 of 1000".</p>
  
  <p>I've read that I need 'Response.Flush' to perform this task, so...</p>
  
  <p>Can I use '.flush' in the loop part of my ASP script, to display the item number (i)? If yes, do I need anything else? If no, can somebody explain what I'll need to do to get it working?</p>
  
  <p>This is what I was thinking:</p>
  
  <pre><code>Response.Buffer = True
  Response.Expires = -1
  i = 0
  total = 1000
  Do Until i = total
  i = i + 1
  Response.Write "Processing Item "&amp;i&amp;" of "&amp;total&amp;""
  Response.Flush
  Loop
  </code></pre>
  
  <p>Many thanks in advance</p>