简体   繁体   中英

Passing data from Javascript back to Python

I am working on webapp2 python framework and wanted to pass data from the javascript back to python. I have dropdown and every time i trigger the change event, i want the value to be captured and query to be executed with the selected value.

test='';
js_code_week_selected ='''<script type="text/javascript">
                          var selected='';
                          selected = $('#selectedlist').text();alert(selected);
                          $('#selectedlist').change(function () {
                          var firstDropVal = $('#selectedlist').val();
                          '''+test+''' = firstDropVal;
                          alert(firstDropVal);
                           });
                          </script>  '''
self.response.out.write(js_code_week_selected)
logging.info(test);

Cross Origin support is required

Have a look into enable-cors.org and you can test virtually at http://client.cors-api.appspot.com/client

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM