我有一个小脚本已经使用ajax来获取
但我也希望在歌曲开始播放时更新我的数据库
mySQL表:
tbl_tracks:
id | track_name | album_id | track_play_count | track_like_count
1 some song 12 3 1
2 some song 13 9 4
这是我的ajax代码:
$(window).load(function() {
var audio;
var playlist;
var tracks;
var current;
// $('.Mp3Link').click(); this will click something upon entry
init();
function init() {
current = 0;
audio = $('audio');
playlist = $('#playlist');
tracks = playlist.find('li a');
len = tracks.length - 1;
audio[0].volume = 1;
audio[0].play();
playlist.find('a').click(function(e) {
e.preventDefault();
link = $(this);
current = link.parent().index();
run(link, audio[0]);
});
audio[0].addEventListener('ended', function(e) {
$('.lSNext').click();
current++;
if (current == len) {
current = 0;
link = playlist.find('a')[0];
} else {
link = playlist.find('a')[current];
}
run($(link), audio[0]);
});
}
function run(link, player) {
player.src = link.attr('href');
par = link.parent();
par.addClass('active').siblings().removeClass('active');
audio[0].load();
audio[0].play();
}
});
那么我每次开始新歌时如何更新 track_play_count 呢?
非常感谢你提前