
// make asynchronous HTTP request using the XMLHttpRequest object 
function vote_forward(id,s)
{
	iid=id;
	ds=s;
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    
    // execute the quickstart.php page from the server
    xmlHttp.open("GET", "inc/function_forward.php?id=" + iid +"&s="+ds+"&t="+ Math.random(), true);  
    // define the method to handle server responses
    xmlHttp.onreadystatechange = handleServerResponsef;
    // make the server request
    xmlHttp.send(null);
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('vote_forward(iid,ds)', 1000);
}

// executed automatically when a message is received from the server
function handleServerResponsef() 
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
	  
      xmlResponse = xmlHttp.responseText;
	  if(xmlResponse !=''){
	  alert(xmlResponse);
	    if(xmlResponse=='恭喜你投票成功'){
	     window.location.href = window.location.href;
		}
	  }else{
	  alert('nothing');
	  }
	}
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}
