久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <small id='FOl4D'></small><noframes id='FOl4D'>

    2. <legend id='FOl4D'><style id='FOl4D'><dir id='FOl4D'><q id='FOl4D'></q></dir></style></legend>
      <i id='FOl4D'><tr id='FOl4D'><dt id='FOl4D'><q id='FOl4D'><span id='FOl4D'><b id='FOl4D'><form id='FOl4D'><ins id='FOl4D'></ins><ul id='FOl4D'></ul><sub id='FOl4D'></sub></form><legend id='FOl4D'></legend><bdo id='FOl4D'><pre id='FOl4D'><center id='FOl4D'></center></pre></bdo></b><th id='FOl4D'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FOl4D'><tfoot id='FOl4D'></tfoot><dl id='FOl4D'><fieldset id='FOl4D'></fieldset></dl></div>
        • <bdo id='FOl4D'></bdo><ul id='FOl4D'></ul>

        <tfoot id='FOl4D'></tfoot>

        如何將數據從 Flask 發送到 JavaScript?

        How I can send data from Flask to JavaScript?(如何將數據從 Flask 發送到 JavaScript?)

              <legend id='oliix'><style id='oliix'><dir id='oliix'><q id='oliix'></q></dir></style></legend>
            1. <tfoot id='oliix'></tfoot>

              <i id='oliix'><tr id='oliix'><dt id='oliix'><q id='oliix'><span id='oliix'><b id='oliix'><form id='oliix'><ins id='oliix'></ins><ul id='oliix'></ul><sub id='oliix'></sub></form><legend id='oliix'></legend><bdo id='oliix'><pre id='oliix'><center id='oliix'></center></pre></bdo></b><th id='oliix'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='oliix'><tfoot id='oliix'></tfoot><dl id='oliix'><fieldset id='oliix'></fieldset></dl></div>
                <bdo id='oliix'></bdo><ul id='oliix'></ul>
                • <small id='oliix'></small><noframes id='oliix'>

                    <tbody id='oliix'></tbody>
                • 本文介紹了如何將數據從 Flask 發送到 JavaScript?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  您好,我是新手,正在使用 Flask 和 Javascript 構建應用程序.我從 Flask do JavaScript 發送數據時遇到問題.

                  Hello I am new and building an application in Flask and Javascript. I have a problem with sending data from Flask do JavaScript.

                  我在 routes.py 中有代碼

                  I have code in routes.py

                  @app.route('/mapaa',methods=['GET','POST'])
                  def mapa():
                      user_id = current_user.get_id()
                      slownik = {}
                  
                  
                      if 'event_form' in request.form:
                          name = request.form['name_event']
                          all_data = Event.query.filter_by(name=name).all()
                          for row in all_data:
                              date_st_string = str(row.date_start)
                              date_end_string = str(row.date_end)
                              slownik = {'id':row.id,'date_st':date_st_string,'date_end':date_end_string,'type':row.type,'name':row.name,'len_route':row.len_route,'route':row.route}
                          return jsonify(slownik)
                      return render_template('mapaa.html', title='Mapa')
                  

                  我想用 JavaScript 將 jsonify(slownik) 發送到我的代碼,但我不想用 render_template 這樣做,因為它會刷新頁面,我需要這些數據使用 JavaScript 在地圖上顯示它.我嘗試了 return jsonify(slownik) 但它在新頁面上返回了我的數據.當用戶單擊 event_form 按鈕而不刷新頁面時如何將數據發送到 JavaScript?

                  I want to send jsonify(slownik) to my code in JavaScript but I dont want to do it with render_template bacause it refresh a page and I need this data to display it on the map using JavaScript. I tried return jsonify(slownik) but it return me the data on new page. How I can send the data when the user click event_form button to JavaScript without refreshing page?

                  推薦答案

                  您可以使用ajax 發送post 請求而無需刷新頁面.注意 - 在此之前包含 jquery

                  You can use ajax for sending post request without refreshing the page. Note- include jquery before this

                  <script src="https://code.jquery.com/jquery-3.1.0.js" ></script>
                  

                  javascript 代碼

                  javascript code

                  $("#id_of_btn").click(function () { // make ajax request on btn click
                    $.ajax({
                      type: "POST",
                      url: "/mapaa", // url to the function
                      data: {
                        name: $("#id_of_input_tag").val(), // value of the form
                      },
                      success: function (response) {
                        console.log(response); // response contains the json
                      },
                    });
                  });
                  

                  確保你不使用表單標簽.

                  make sure you don't use form tag.

                  如果您想通過表單發送更多數據,您可以使用

                  If you want to send more data via forms, you could use

                  data: $('form').serialize()
                  

                  這將獲取輸入標簽的名稱屬性并將其添加到request.data中所以如果你有這個

                  this will take the name attribute of input tag and add it in the request.data So if you have this

                  <input type="text" id="element_id" name="username" > 
                  

                  您可以像這樣使用 name 屬性的值 request.data['username']按照這個 教程

                  You can use the value of name attribute like this request.data['username'] follow this tutorial

                  這篇關于如何將數據從 Flask 發送到 JavaScript?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發點擊傳單標記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                  Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在彈出窗口中獲取標記的緯度和經度)
                • <legend id='7dhi5'><style id='7dhi5'><dir id='7dhi5'><q id='7dhi5'></q></dir></style></legend>
                      <bdo id='7dhi5'></bdo><ul id='7dhi5'></ul>
                        <tbody id='7dhi5'></tbody>

                        <tfoot id='7dhi5'></tfoot>
                      1. <small id='7dhi5'></small><noframes id='7dhi5'>

                        • <i id='7dhi5'><tr id='7dhi5'><dt id='7dhi5'><q id='7dhi5'><span id='7dhi5'><b id='7dhi5'><form id='7dhi5'><ins id='7dhi5'></ins><ul id='7dhi5'></ul><sub id='7dhi5'></sub></form><legend id='7dhi5'></legend><bdo id='7dhi5'><pre id='7dhi5'><center id='7dhi5'></center></pre></bdo></b><th id='7dhi5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7dhi5'><tfoot id='7dhi5'></tfoot><dl id='7dhi5'><fieldset id='7dhi5'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 亚洲第一区久久 | 国产一区二区免费 | 96av麻豆蜜桃一区二区 | 欧美一区视频在线 | 欧美成人精品一区二区男人看 | 久久精品欧美一区二区三区不卡 | 亚洲国产成人精品久久久国产成人一区 | 国产精品伦理一区二区三区 | 一级黄色毛片免费 | 日韩av一区二区在线观看 | 黄色大片在线免费观看 | 久久久久久艹 | 久久精品视频一区二区三区 | 精品国产一区二区在线 | 中文字幕精品一区二区三区精品 | 成人免费在线观看视频 | 久久久精品一区二区三区四季av | 日本成人中文字幕在线观看 | 日本一区二区在线视频 | 日韩欧美专区 | 成年男女免费视频网站 | 在线观看www视频 | 蜜桃视频一区二区三区 | 在线观看成人 | 国产午夜精品一区二区三区嫩草 | 免费高潮视频95在线观看网站 | 日本精品一区二区三区在线观看 | 人人干在线 | 91精品国产乱码麻豆白嫩 | 亚洲精品福利视频 | 国产中文| 日韩欧美在线播放 | 黄色永久免费 | 一区精品国产欧美在线 | 精品国产精品三级精品av网址 | 91观看 | 亚洲综合一区二区三区 | 日韩成人一区二区 | 亚洲精品日韩视频 | 中文字幕日韩一区 | 久久亚洲国产 |