All pastes #454044 Raw Edit

Joe

public javascript v1 · immutable
·published 2007-04-23 11:22 UTC
rendered paste body
var xmlHttpfunction confirm_join(str)  {var r=confirm('Are you sure you want to do this?/nYou have '+str+' changes left.')  if (r==true)    {xmlHttp=GetXmlHttpObject();if (xmlHttp==null)  {  alert ("Your browser does not support AJAX!");  return;  }    aid=document.getElementById("aid").value;var url="alliance_join.php";url=url+"?confirm=1&aid="+aid;xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null);    } else { alert('okay'); }}function stateChanged() {if (xmlHttp.readyState==3){ document.getElementById("join").value='Joining...';}if (xmlHttp.readyState==4){   document.getElementById("join").value='Try again';     if (xmlHttp.responseText == 'Success') {     window.location = join_alliance.php?success=1;     document.getElementById("join").value='Joined';     document.getElementById("join").disabled='disabled';     document.getElementById("error").innerHTML='Done';     }     else {     document.getElementById("error").innerHTML='An unknown error occured';     }}}function GetXmlHttpObject(){var xmlHttp=null;try  {  // Firefox, Opera 8.0+, Safari  xmlHttp=new XMLHttpRequest();  }catch (e)  {  // Internet Explorer  try    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }  catch (e)    {    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");    }  }return xmlHttp;}---------------		<input type="hidden" value="<?=$_GET[aid]?>" id="aid"/>		<input type="button" value="Join" onClick="confirm_join('4')" id="join"/>