Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
  <meta charset="utf-8">
  <title>XHR requests to external data</title>
</head>
<body>
<p>The JS in this bin does all the work, but the actual data that's used to respond to the ajax request is stored in a completely separate bin.</p>
  <ul id="out"></ul>
</body>
</html>
 
var $out = $('#out');
setTimeout(function () {
  var request = $.ajax('//jsbin.com/megax.json', {
     dataType: 'json'
   });
  
  request.then(function (result) {
    var html = '<li><strong>Loaded from external bin: <code><a href="http://jsbin.com/megax/edit?js">megax</a></code></strong></li>';
    $.each(result, function (key, value) {
      html += '<li>' + key + ': ' + value + '</li>';
    });
    $out.html(html);
  }, function () {
    alert('The request failed');
  });
}, 1000);
Output

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

Dismiss x
public
Bin info
rempro
0viewers