Home > front end >  Flask and ajax push the json data to the front end of a few places
Flask and ajax push the json data to the front end of a few places

Time:01-16

With the flask
The json string can be got, but with ajax when pushed to the front show not to come out, ask bosses solve, have died in this two hours, help!
Datas={" nowConfirm ":" 1729 ", "confirm_add" : "173", "confirm" : "98290", "dead" : "4803", "at heal" : "91758"}

Flask:

@ app. The route ('/get_column_no ', the methods=[' get 'and' post '])
Def get_column_no () :
# access to data in the database
Res=utils1. Get_column_no ()
Datas=jsonify ({" nowConfirm ": STR (res) [4]," confirm_add ": STR (res [1]),
"Confirm" : STR (res) [0], "dead" : STR (res) [3], "at heal" : the STR (res) [2]})
Return datas










  • Existing confirmed & lt;/li>
  • The new confirmed & lt;/li>











  • The cumulative confirmed & lt;/li>
  • The cumulative death & lt;/li>
  • The cumulative cure & lt;/li>






The function get_column_no () {
$. Ajax ({
Url:/get_column_no,
Type: "post",
Success: the function (datas) {
$(". No - hd ul li "). The eq (0). The HTML (datas [' nowConfirm '])
$(". No - hd ul li "). The eq. (1) the HTML (datas [' confirm_add '])
$(". No - hd ul li "). The eq. (2) HTML (datas [' confirm '])
$(". No - hd ul li "). The eq. (3) HTML (datas [' at heal])
$(". No - hd ul li "). The eq. (4) HTML (datas [' dead '])
},
Error: function () {

}
})
}

Get_column_no ()
  •  Tags:  
  • Ajax
  • Related