Forums

javascript in html not working in pythonanywhere

I am having javascript and Ajax in my html file. Calling DB and updating. It is working fine in my laptop. But not in pythonanywhere.com (evisionsoft.pythonanywhere.com) . I am not using any .js file. only in html. Please advise.

Hi, have you set static files mappings in your Web app? We have a help page on that https://help.pythonanywhere.com/pages/StaticFiles/ .

Hi, I followed the instruction in both script and external file and still not working the java script. Please help thanks, Noel

<html>
   <head>
      <script type="text/javascript">
         var myVar="hello";
         function exampleFunction() { alert('You triggered an alert!'); }
      </script>
   </head>
   <body>
      <p><a href="#" onClick="exampleFunction;">Click Me</a></p>
   </body>
</html>

It runs in the browser, not on the PythonAnywhere. You need to use your browser's dev tools to debug it.

Hi pafk,

It's okey now. It needs the assets folder for the url to work. also the code I copied from the example have missing "(): after the function name. Thanks,

Great! Glad you got it working.