Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Scripts as part of HTML code created on server

I'm trying to send part of html code generated by server. The code is shown in modal window and everything works except javascript.

I have created small example. The code I'm sending from server (inserted directly into modal body):

<div class="container-fluid">
   <div class="row row-cols-1 row-cols-lg-2 g-4">
      <div class="col">
     <div class="card h-100">
        <div class="card-body">
                <button class="btn btn-primary" type="button" id="MesuringDevicesButton" title="Test" onclick="addDevice()"><span class="material-icons-outlined">add</span></button>
        <script type="text/javascript" src="/sls/layouts/measuringdevices_v1.js"></script>
            </div>
     </div>
      </div>
  </div>
</div>

content of javascript file:

function addDevice(){
   console.log("MeasuringDevices button onclick method.");
}

The problem is, that console writes me error:

109:1 Uncaught ReferenceError: addDevice is not defined at HTMLButtonElement.onclick (109:1:1)

when I load the JS file in page (and not sending the <script> part from server) it works...

Do you know what I'm doing wrong?

Many thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!