KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following script element in my web page: <script src="default.js" type="text/javascript"></script> Using JavaScript, I want to be able to retrieve the content of the script file. I know I could use an ajax request to get the data but then I am getting something from the server that I already have locally. So what I would prefer to do is retrieve the content from the DOM (if that's possible) or something that has the same result. Cheers Anthony UPDATE I was trying to simplify the question, maybe a bad a idea, I thought this way would cause less questions. The real situation I have is as follows, I actually have <script type="text/html" class="jq-ItemTemplate_Approval"> ... html template that is going to be consumed by jQuery and jTemplate ... </script> Now this works fine but it means each time the page loads I have to send down the template as part of the HTML of the main page. So my plan was to do the following: <script src="template.html" type="text/html"></script> This would mean that the browser would cache the content of template.html and I would not have to send it down each time. But to do this I need to be able to get the content from the file. Also in this case, as far as I know, requesting the content via ajax isn't going to help all that much because it has to go back to the server to get the content anyway.
Tags (comma-separated)
Save Edits
Cancel