python - How to update session object -


with 2 <a>:

<a id="100" onclick="createtriggered(this.id)"<i></i> click link </a> <a id="200" onclick="createtriggered(this.id)"<i></i> click link </a> 

both linked same onclick javascript function:

<script type=text/javascript>   $script_root = {{ request.script_root|tojson|safe }};   function onclick(id){       var data = $.getjson($script_root + '/triggered', {a:id} );       window.alert({{ "session.keys()" }});   } </script>  

this javascript function takes clicked <a> id , sends flask function:

@app.route('/onclick') def onclick():     session['a_id'] = request.args.get('a')     return ('ok') 

after flask function gets id updates session object creating new key session['a_id'].

finally javascript window.alert used check if session object has new 'a_id' key should set flask function. when window.alert pops shows new key missing. refreshing page , re-clicking <a> link pop window.alert() again time showing new session['a_id'] key there. looks update of session object lagging behind. have refresh page in order browser pick change made flask function. there way assure update made flask function session object reflected immediately? finally, since updating session object global entire session don't want return template or redirect link. want flask function set session variables used somewhere down logic. ok return dummy string flask function in case?


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -