Flask fullchallender.js ajax クリックした日付に対応した情報をFlask側に送る
これも全然難しい話ではなかったのだが、凡ミスでつまずいた。
//callender.js const my_cal = function(){ $(document).ready(function() { $('#calender').fullCalendar({ dayClick: function(date, jsEvent, view) { const send_date = JSON.stringify(date.format('YYYY-MM-DD')); $.ajax({ type:'POST', url:'/fetchday', dataType:'json', data:send_date, contentType:'application/json', success:function(success_data){ console.log(success_data); }, error: function(error) { console.log("error"); console.log(error); } }); return false; } }); }); }
#app.py @app.route('/fetchday', methods=['POST']) def fetch_day_data(): get_json = request.json print(get_json) return_json = { "hello":"world" } return Response(json.dumps(return_json))
これで動くかな。ところどころ端折ってい待っているので動かないかも。