You are not going to be able to
dynamically set the
src of a
script tag that references
?act=API_GenResultsTable&jht=1. This is because that script file references
document.write() and that method operates
differently between when it is called on initial page load and when it is called later.
Moreover, nobody uses
document.write() anymore. It is archaic construct left over from the early days of the web and is only used for some obscure edge cases related to having a backup for a missing CDN file. If you are writing your own code page and want to use
?act=API_GenResultsTable call it with
&jsa=1 instead and generate your report using a template such as
Mustache. Search for
API_GenResultsTable and
Mustache for historic examples and I think you will find material you can adopt.