Javascript not working properly (Moodle 3.3+)

Javascript not working properly (Moodle 3.3+)

by Madhu Avasarala -
Number of replies: 2

I have a database activity for a staff leave management system. The JS is not working on Moodle 3.3+. I tested the code on my chrome browser using .js file with save script as pasted in Moodle template with a dummy table generated, and it works fine.

When I look at Chrome dev tools I get the following:

______________________________________________________________________________________________

Failed to load resource: the server responded with a status of 404 (not found)

codemirror.css Failed to load resource: the server responded with a status of 404 (not found)

fullscreen.css Failed to load resource: the server responded with a status of 404 (not found)

js.php:15 Uncaught TypeError: Cannot read property 'getElementsByTagName' of null

    at calc_totals (js.php:15)

    at js.php:63

jquery.dataTables.css Failed to load resource: the server responded with a status of 404 (not found)

fullscreen.css Failed to load resource: the server responded with a status of 404 (not found)

codemirror.css Failed to load resource: the server responded with a status of 404 (not found)

__________________________________________________________________________________________

The js.php looks like my code. The other errors seem due to configurable Reports plugin (that is throwing errors in Moodle 3.3).

My preset is attached.


Thanks for any light on this. Madhu Avasarala

Average of ratings: -
In reply to Madhu Avasarala

Re: Javascript not working properly (Moodle 3.3+) Solved

by Madhu Avasarala -

The problem was the statement:

windows.onload = myfunction();

by modifying it to:

windows.onload = myfunction;

all problems went away! This is not flagged as a syntax error but just gets choked on! same code works fine locally on pc on the chrome browser. Terrible debug!

Sorry about this.

Average of ratings: Useful (1)
In reply to Madhu Avasarala

Re: Javascript not working properly (Moodle 3.3+)

by Ambrish Tiwari -

Hello Madhu

Find the moodle data folder. Inside the moodle data there are many folder

  1. Delete all from Cache
  2. Delete all from Session

Restart your browser.

It worked for me. Hope that works for you.