Sometimes I use the following workaround with a temporary placeholder string:
var variable1 = "someString";
$('#demo').load(
"{{ url_for('addshare2', share="ADDSHARE2") }}".replace("ADDSHARE2", variable1)
);
It doesn’t feel quite right and I’m still looking for a better solution. But it does the job.