我想从 JavaScript 以字符串形式访问 HTML 文件 (makemeastring.html
)。 jQuery 的 .load
似乎不起作用。
最佳答案
$.get('makemeastring.html').then(function (data) {
console.log(data);
}).fail(function () {
// Error occurred, handle it here
});
jQuery 的 .load()
函数将数据放入 DOM 元素中。你不希望这样,所以 .get()
就可以了。
关于javascript - 如何通过 HTTP 将 HTML 文件加载到字符串中以便在 JavaScript 中使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28388101/