0

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?

  • An internal server error most likely isn't caused by (your) JS. Trying looking at the logs on the server if you can. They should tell you more – Reyno Aug 03 '21 at 12:47
  • Indeed, I really do not get why my code does not work with the JS function and does work without the JS functions. Until know I could not figure out the underlying problem with the function. I agree that is does not make sense that the JS function causes any server problems. However, with the JS function on the page I cannot continue to the next page. I only get the error message "internal server error". – Nicki Maier Aug 03 '21 at 12:53
  • *The problem seems to be* - what it *seems* to be is irrelevant - what *exactly* is causing the problem. Debug to find out. Remove the code you think causes the problem - still a problem? Not that code. – freedomn-m Aug 03 '21 at 13:13

0 Answers0