Michael Schwartz
Michael Schwartz

Reputation: 8425

Load HTML Page In Textarea

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.

Upvotes: 1

Views: 3838

Answers (2)

Orel Eraki
Orel Eraki

Reputation: 12196

I would suggest you to try this one:

input.val(mirror.load('startup.html').html());

Upvotes: 0

try this

$(function () {
    function download_to_textbox(url, el) {
        $.get(url, null, function (data) {
            el.val(data);
        }, "text");
    }
    download_to_textbox("startup.html", $("#textareaID"));
});

Upvotes: 1

Related Questions