This topic is locked

External JS loads but is not callable...

4/23/2024 6:40:35 PM
PHPRunner General questions
B
bleigh@yucatech.com authorDevClub member

I followed this article: https://xlinesoft.com/asprunnerpro/docs/how_to_add_external_files.htm

I can see in network tab of chrome that my shared script is loaded and the function is there but when I try to run a function out of it, it says sharedExternalFunction is not defined.

I have a similar function named sharedCustomFunction in custom_functions.js for each page and that is called correctly. I'm baffled as to why this isn't working

I even copied the custom function into the shared file to make sure there were no typos and its still broken.

header.htm

<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{$pagetitle}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<base href="{$projectPath}">
<script type="text/javascript" src="include/shared_functions.js"></script>

Custom button:

function OnBefore(pageObj,params,ajax,ctrl,row) {
sharedCustomFunction(); <<< This one logs to the console
sharedExternalFunction(); <<< This one says the function is not defined.
}

custom_functions.js

function sharedCustomFunction() {
console.log("shared custom function called");
}

shared_functions.js

function sharedExternalFunction() {
console.log("shared external function called");
}