Eric the Red
Eric the Red

Reputation: 5454

How can I get the contents of an external script?

I have a handlebars template in a public directory. I'd like to access the contents of this file with JavaScript. Here's the code for the script:

<script id="test_template" type="text/template" src="/templates/test.hbs"></script>

If I dump out the contents of the file inside the script tag (instead of using the "src" attribute) I can easily get at the contents, but then I won't get any caching.

Is it possible to get the contents of this file without using an AJAX call?

Upvotes: 2

Views: 211

Answers (1)

tmcw
tmcw

Reputation: 11882

Is it possible to get the contents of this file without using an AJAX call?

No, you'll need to use an AJAX call.

Upvotes: 1

Related Questions