I have developed an online experiment with oTree which is a framework for developing experiments.
I have implemented the following codes for the measurement of the input values in a form field:
$('document').ready(function () {
$('#id_decl_ic_2').on('input', function () {
input_value = $('#id_decl_ic_2').val();
clearTimeout(timeout)
timeout = setTimeout(function () {
if ($('#id_decl_ic_2').val() == input_value) {
form_id = "formfield_ic_2";
counter_2++;
ip_time = Date.now();
input = {
form_id: form_id,
input_counter: counter_2,
input_time: ip_time,
input_value: input_value,
}
}
console.log(input);
}, 1000)
})
})
The code perfectly works on the local server (the development server of oTree) and I assume also on every normal webpage.
I hosted my experiment on the cloudserver Heroku. There the function causes an internal server error. The same happened with the following JS function:
window.onload = function() {
//do smomething
};
The problem seems to be the respective query selector and the JS handler.
Did anyone ever encounteres the same problem? Does anyone have a solution for the problem? Can I try other event handlers?