There are several possibilities:
xhttp.open("GET", "emotionDetector?textToAnalyze"+"="+textToAnalyze, true);
But this results in a malformed URL, instead try using
xhttp.open("GET", "emotionDetector?textToAnalyze=" + encodeURIComponent(textToAnalyze), true);
The use of encodeURIComponent makes sure any funny stuff in the text, such as special characters gets encoded properly.
src="../static/mywebscript.js"
This means your JavaScript file is expected to be in a static folder at the root level. Flask serves static files from a static/ directory inside your project folder. Try referencing it as
src="{{ url_for('static', filename='mywebscript.js') }}"
Good Luck =D