Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="73 - AJAX -Deferreds" />
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div id="resultado"></div>
</body>
</html>
 
$(document).ready(function() {
  getDatos("batman");
  getDatos("superman");
  getDatos("batman");
});
var api = {};
function getDatos(busqueda) {
  if (!api[busqueda]) {
    var url = "http://www.omdbapi.com/?s=" + busqueda + "&callback=?";
    console.log("Petición a " + url);
    api[busqueda] = $.getJSON(url);
  }
  
  api[busqueda].done(todoOk).fail(function() {
    $("#resultado").html("Error");
  });
}
function todoOk(datos) {
    console.log("Datos recibidos y adjuntándolos a resultado");
    $("#resultado").append(JSON.stringify(datos));
}
Output 300px

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

Dismiss x
public
Bin info
aitormedran0pro
0viewers