is it possible to make an AJAX request within a loop. I am trying to request some info from my db via php for a known number of times but it doesn't seem to work. The function reaches as far as the alert(value) but nothing further. The code is shown below
get_bookmarks.php
PHP Code:
<?php
 $id 
$_REQUEST['id'];
 
//$id=$_GET['id'];
 
$con mysql_connect("localhost","root","");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }
mysql_select_db("joomla"$con);

//query databases for a result
$result mysql_query("SELECT * FROM jos_content where id='$id'");

while(
$row mysql_fetch_array($result))
 {
    echo 
"<li><a href=\"JavaScript:article('$id')\">".$row['title']."</a> </li>";
 }
?>
bookmarks.html
HTML Code:
<html>
	<head>
		<title>List Bookmarks</title>
	</head>
	<body>
		<script>
		
		window.onload = function() {
		displaybookmarks();
		};
		
		function article(Article) {
 
		  HttPRequest = false;
		  if (window.XMLHttpRequest) { // Mozilla, Safari,...
			 HttPRequest = new XMLHttpRequest();
			 if (HttPRequest.overrideMimeType) {
				HttPRequest.overrideMimeType('text/html');
			 }
		  } else if (window.ActiveXObject) { // IE
			 try {
				HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {
				try {
				   HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			 }
		  } 
 		  if (!HttPRequest) {
			 alert('Cannot create XMLHTTP instance');
			 return false;
		  }
 			var url = 'includes/article_desc.php';
			var pmeters = '&Article='+Article;
			HttPRequest.open('POST',url,true);
 
			HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			HttPRequest.setRequestHeader("Content-length", pmeters.length);
			HttPRequest.setRequestHeader("Connection", "close");
			HttPRequest.send(pmeters);
 
 
			HttPRequest.onreadystatechange = function()
			{
 			if(HttPRequest.readyState == 3)  // Loading Request
				  {
			document.getElementById("listarticles").innerHTML = '<img src="images/spiral.gif" align="center" />';
				  }
 				 if(HttPRequest.readyState == 4) // Return Request
				  {
					var response = HttPRequest.responseText;
					document.getElementById("listarticles").innerHTML = response;
				  }
 			}
 			   }	
			
			
			function displaybookmarks(){
				for(var i=0;i<localStorage.length;i++)
					{
						var keyName = localStorage.key(i);
						var value = localStorage.getItem(keyName);
						alert(value);
						function getbookmarks(id);
					}
			}
		
		function getbookmarks(id) {
 
		  HttPRequest = false;
		  if (window.XMLHttpRequest) { // Mozilla, Safari,...
			 HttPRequest = new XMLHttpRequest();
			 if (HttPRequest.overrideMimeType) {
				HttPRequest.overrideMimeType('text/html');
			 }
		  } else if (window.ActiveXObject) { // IE
			 try {
				HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {
				try {
				   HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			 }
		  } 
 		  if (!HttPRequest) {
			 alert('Cannot create XMLHTTP instance');
			 return false;
		  }
 			var url = 'includes/getbookmarks.php';
			var pmeters = '&id='+value;
			HttPRequest.open('POST',url,true);
 
			HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			HttPRequest.setRequestHeader("Content-length", pmeters.length);
			HttPRequest.setRequestHeader("Connection", "close");
			HttPRequest.send(pmeters);
 
 
			HttPRequest.onreadystatechange = function()
			{
 			if(HttPRequest.readyState == 3)  // Loading Request
				  {
			document.getElementById("listarticles").innerHTML = '<img src="images/spiral.gif" align="center" />';
				  }
 				 if(HttPRequest.readyState == 4) // Return Request
				  {
					var response = HttPRequest.responseText;
					document.getElementById("listarticles").innerHTML = response;
				  }
 			}
 			   }	
			
						
		
		</script>
	<div id="listarticles"></div>	
	</body>
</html>