Sorry for the typo , just fixed it.
Although I ended up taking the code from exported_func2_code and putting it in a separate perl script which I redirect from the button's onClick function .. although I'd like to know what the issue is by using perl ajax.