I need to load an .js file after an ajax call. I've been looking for and found $.getScript('')
to call my file, it opens, everything works fine, but the functions defined in that file are not being found.
I have a clicklistener function defined like this:
var record = $('#record');
record.onclick = function () {
startTimer(1);
mediaRecorder.start(50);
console.log("recorder started");
}
When I click the button with the id record
nothing happens. I already tried to put a name in this function and call it on the button:
<button type="button" onclick="javascript:startRecord();" id="record">Record</button>
but also not recognized. What is the correct technique to do what I want?
Note: I do not put the script on the page (before ajax call) because I need values and DOM elements that result from this call. I am working on MVC, the ajax call is in a razorView returns html resulting from a controller