Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <button id='mkReq' >Send Req</button>
  <div id='msg'></div>
  <br/>
  See what the server gets <a href="http://requestb.in/1d03gpm1?inspect" target="_BLANK">here</a>
</body>
</html>
 
var url = 'http://requestb.in/1d03gpm1';
var body = 'rand=';
var button = document.getElementById('mkReq');
var msg = document.getElementById('msg');
var randToken = Math.ceil(Math.random() * 1000000);
msg.innerHTML = 'token '+ randToken;    
function echo (e) {
  if (e.target.readyState === 4) {
    msg.innerHTML = randToken + ' Success';
  }
}
function callOtherDomain(){
  var invocation = new XMLHttpRequest();  
  invocation.open('POST', url, true);
  invocation.onreadystatechange = echo;
  invocation.send(body + randToken); 
  msg.innerHTML = randToken + ' Sending...';
}
button.addEventListener('click', callOtherDomain);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers