.load isnt a blocking function, meaning that it starts the ajax request and
then continues the chain. So you might try something like this:
$('<pre>').load('jquery.splitter.js',function() {
// Do escaping stuff here
});
The 2nd argument to load is a function that will be called once the request
is completed.
On 7/15/07, Stephan Beal <[EMAIL PROTECTED]> wrote:
Hiya!
i'm attempting to load a text file via .load() and insert it into a
separate element by fetching the loaded text via text(). Load is
working fine for me. e.g.:
$
('<pre>').appendTo( '#SplitterPaneBottom').load('jquery.splitter.js');
no problem - that appends a PRE to #SplitterPaneBotton and populates
it.
However, i would prefer to internally fetch the text, a-la:
var txt = $('<pre>').load('jquery.splitter.js').text();
(i've also tried .html())
But that is always returning an empty string, whereas i would expect
it to return the contentx of the generated PRE element.
What fundamental clue am i overlooking here?
The main thing i'm looking to do is essentially get load()-like
behaviour but force the fetched text go through text(fetchedText) so
that HTML entities get escaped. If there was a .loadText() i would be
using it instead.
PS: Note that i only use a .js file for input as a test case here -
the contents of the text does not play a role here, as i am only
testing things out for later use in an application.