Skip to content

Instantly share code, notes, and snippets.

@edinsoncs
Created December 10, 2015 02:24
Show Gist options
  • Save edinsoncs/47247bcf7d9473c5397e to your computer and use it in GitHub Desktop.
Save edinsoncs/47247bcf7d9473c5397e to your computer and use it in GitHub Desktop.
Api Url Json
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>JsonWeb</title>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<section id="content">
<form class="json">
<input type="text" class='to'>
<input type="submit" placeholder="json">
</form>
</section>
<script>
/*function createElement(element, text) {
var create = element;
var create_Two = document.createElement(create);
var textCreate = text;
var textCreate_Two = document.createTextNode(textCreate);
var a = create_Two.appendChild(textCreate_Two);
if(a.length === 0 || a.length <= 2) {
return "Error";
}
else {
return console.log('Acceso Permitido');
var toAdd = document.getElementById("content");
document.body.insertBefore(create_Two, toAdd);
}
}
createElement('h1', 'Ingresa url');*/
(function(){
$(".json").submit(function(e){
e.preventDefault();
var obj = {};
var URL = $('.to').val();
var API = "http://query.yahooapis.com/v1/public/yql?q=";
var API_BUSQUEDA = encodeURIComponent('select * from html where url="'+URL+'"');
var API_FORMAT = "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
$.getJSON(API+API_BUSQUEDA+API_FORMAT, laF, false);
function laF(data) {
var a = JSON.stringify(data);
document.write(a);
}
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment