I have here an HTML page which is supposed to be fetching a list of data, but apparently due to server migration ASP is not working. So I want to fetch data without using any language but just pure JavaScript and an HTML page. I think that storing my data in a text file (.txt) and fetching it via JavaScript will do. And the condition will be every month there is different text file to be fetched. Is this possible?
1 Answer
$(document).ready(function(){
$.ajax({
url: "https://www.w3.org/TR/PNG/iso_8859-1.txt"
}).done(function(response) {
$('#data').html(response);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="data"></p>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$.ajax({
url: "https://www.w3.org/TR/PNG/iso_8859-1.txt"
}).done(function(response) {
$('#data').html(response);
});
});
</script>
</head>
<body>
<div id="data"></p>
</body>
</html>
$.get('http://path/to/file.txt', function(data) { $("#target").html(data); });<!--#include file="filename.html"-->