I am working on a classic ASP project and unfortunately cannot switch to another technology. I learned that it's possible to write server side classic ASP code in Javascript (ES3) so I did some investigation but I cannot find a way to include another JS based ASP file from my JS based ASP file.
Here is the JS based ASP file I want to import:
includejs.asp
<%@ Language=JavaScript %>
<%
function myFunction(p1, p2) {
return p1 + p2;
}
%>
And I tried the following 2 ways, neither worked
myjs1.asp
<%@ Language=JavaScript %>
<script language="JScript" runat="server" src="./includejs.asp"></script>
<%
// myFunction is from another file
Response.Write(myFunction(20,2));
%>
myjs2.asp
<%@ Language=JavaScript %>
<!--#include virtual="./includejs.asp" -->
<%
// myFunction is from another file
Response.Write(myFunction(20,2));
%>
My findings
I was able to import a pure javascript file like the following with my first attempt
function myFunction(p1, p2) {
return p1 + p2;
}
but I want to include a ASP wrapped javascript so that I can include other files from the included Js file too.