How to Read Text/Properties File From JavaScript
==== fetch.html==========
<html>
<body>
<div>"=="<span id="anand"/>"</div>
<script src="hi.js"></script>
</body>
</html>
======hi.js ============
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
function requestListener() {
document.querySelector("#anand").innerHTML = this.responseText;
};
onload = function() {
var request = new XMLHttpRequest();
request.onload = requestListener;
request.open("GET", "content.properties", true);
request.send();
};
=========anand.properties========
Name=Anand
Age= 26
<html>
<body>
<div>"=="<span id="anand"/>"</div>
<script src="hi.js"></script>
</body>
</html>
======hi.js ============
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
function requestListener() {
document.querySelector("#anand").innerHTML = this.responseText;
};
onload = function() {
var request = new XMLHttpRequest();
request.onload = requestListener;
request.open("GET", "content.properties", true);
request.send();
};
=========anand.properties========
Name=Anand
Age= 26
Comments
Post a Comment