<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<a id="linkdwd">
Download as JSON
</a>
<script>
$.ajax({
url: 'https://randomuser.me/api/',
dataType: 'json',
success: function (data) {
console.log(data.results[0].picture.large);
const jsondt = JSON.stringify(data);
const datafrt = 'data:application/json;charset=utf-8,' + encodeURIComponent(jsondt);
$("#linkdwd").attr("href", datafrt);
$("#linkdwd").attr("download", JSGuid() + ".txt");
}
});
function JSGuid() {
var output, i, j;
output = '';
for (j = 0; j < 32; j++) {
if (j == 4 || j == 8 || j == 16 || j == 20 || j == 28)
output = output + '-';
i = Math.floor(Math.random() * 16).toString(16).toLowerCase();
output = output + i;
}
return output;
}
</script>
</body>
</html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<a id="linkdwd">
Download as JSON
</a>
<script>
$.ajax({
url: 'https://randomuser.me/api/',
dataType: 'json',
success: function (data) {
console.log(data.results[0].picture.large);
const jsondt = JSON.stringify(data);
const datafrt = 'data:application/json;charset=utf-8,' + encodeURIComponent(jsondt);
$("#linkdwd").attr("href", datafrt);
$("#linkdwd").attr("download", JSGuid() + ".txt");
}
});
function JSGuid() {
var output, i, j;
output = '';
for (j = 0; j < 32; j++) {
if (j == 4 || j == 8 || j == 16 || j == 20 || j == 28)
output = output + '-';
i = Math.floor(Math.random() * 16).toString(16).toLowerCase();
output = output + i;
}
return output;
}
</script>
</body>
</html>
0 Comments