问题
I've been trying to load a html document into a textarea when the page loads.
I know you can use the ajax load api in JQuery...
$("#siteloader").load('startup.html');
but if I try to load this into the textarea...
var mirror = $("#pageloader"),
input = $("#pagecode");
input.val(mirror.load('startup.html'));
I get [object Object]
which I figured wouldn't work, but thought I'd try it anyway as I just didn't know if it would work or not.
Any help on how to do this would be greatly appreciated.
回答1:
try this
$(function () {
function download_to_textbox(url, el) {
$.get(url, null, function (data) {
el.val(data);
}, "text");
}
download_to_textbox("startup.html", $("#textareaID"));
});
回答2:
I would suggest you to try this one:
input.val(mirror.load('startup.html').html());
来源:https://stackoverflow.com/questions/18546295/load-html-page-in-textarea