[jQuery] Page initialization document ready

[jQuery] Page initialization document ready


I'm setting default values for a text area on page load. This ivolves
loading a remote xml file. Should I be using the document.read()
function here. Because the "resultdiv" doesn't seem to finish load
names.xml. So none of the manipulations can happen.
----
function init() {
var resultdiv = $("<div id='res' />");
resultdiv.load("names.xml");
var text = $(resultdiv).html()+"\n";
$("#source").val(text);
}
<body onload"init()" >

Source


<textarea id="source" rows="10" cols="30">
</textarea>
</body>