How Can I Get Javascript Code As Text From .js To Be Inserted Into An Html Page?
I'm new on stackoverflow and I apologize in advance for any wrong way to ask a question.
Solution 1:
by ajax:
let xhr = new XMLHttpRequest();
xhr.open('GET', 'test.js');
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
};
Post a Comment for "How Can I Get Javascript Code As Text From .js To Be Inserted Into An Html Page?"