Putting PHP code inside a jQuery change event does not mean that the PHP code is run when the change event happens.
PHP code written this way runs only once, when the page is loaded. This means that it will never know what the
com_code JS variable contains after the click.
This technique is well established, and jQuery provides functions that make it very easy to use. Look up some jQuery Ajax examples, and follow them from there.
Hope that helps.