Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<input class="form-control" type="text" id='username'>
  
  <input class="form-control" type="email" id='email'>
</body>
</html>
 
$.ajax({
  url: 'https://randomuser.me/api/',
  dataType: 'json',
  success: function(data){
    var user = data.results[0].user,
        list = $('.form-control'),
        prop;
    for (var i = 0, len = list.length; i < len; i += 1) {
      prop = user[ $(list[i]).attr('id') ];
      if ( prop ) $(list[i]).val(prop);
    }
  }
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers