我正在尝试使用ajax从数据库加载,而import pandas as pd
from io import StringIO
mystr = StringIO("""Date
01-01-2018
02-02-2018
03-04-2018""")
# if necessary, read data and convert to datetime
df = pd.read_csv(mystr)
df['Date'] = pd.to_datetime(df['Date'], dayfirst=True)
# apply string formatting
df['Date'] = df['Date'].dt.strftime('%d-%b-%Y')
print(df)
Date
0 01-Jan-2018
1 02-Feb-2018
2 03-Apr-2018
方法似乎不起作用。
这是我的源代码:
this
这是我要运行的功能
$(".cancel-btn").click(function() {
var cancelArea = $('.cancel');
let userID = $('.person-title').data('user-id');
$.get(`users/${userID}`).done((docs) => {
$(docs).each((i) => {
$(cancelArea).append(
`<div class='cancel-box text-center' data-sessionID="${docs[i]._id}" onclick='cancelSession()'>
<div class='cancel-trainer'>${docs[i].trainedByName}</div>
<div class='cancel-date'>${docs[i].date}</div>
<div class='cancel-hour'>${docs[i].startTime}</div>
</div>`
);
});
});
});
谢谢!
答案 0 :(得分:1)
试试看
<div class='cancel-box text-center' data-sessionID="${docs[i]._id}" onclick='cancelSession(this)'>
JS:
function cancelSession(element) {
console.log($(element).data('sessionid'));
}