Check to see ff eventistener works/

when I make a change in my select box, how can I tell if the function is firing?


    function postPorts(e){

      var xhr = new XMLHttpRequest();'POST', '../data_connections/port_options.php');
      xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

      xhr.onload = function(){
        document.getElementById('Ports').innerHTML = this.responseText;



One super easy way is to toss a console.log() function call in your function and have it log something to the browser console. Quick and easy to do and will tell you if the function is firing as any time it is triggered it would write a message to the console. Use the console.log to also log out variable values, returned results etc.


Also, given that the function calls an XHR request, you can look at the Network tab of your developer tools to see if it’s sending the request out for the port options…

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.