我正在尝试存储以下数据,取自 html
title:"Tempered Song",
artist:"Miaow",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-01-Tempered-song.mp3",
oga:"http://www.jplayer.org/audio/ogg/Miaow-01-Tempered-song.ogg",
poster: "http://www.jplayer.org/audio/poster/Miaow_640x360.png"
我的html代码是:
<a class="add-music" data-title="Las Voces" data-artist="" href="audios/song-little.mp3">Add to List</a>
<a class="download-music" href="audios/song-little.mp3">Download</a>
<a class="add-music" data-title="Las Voces del Bosque" data-artist="" href="audios/song-little.mp3">Add to List</a>
<a class="download-music" href="audios/song-middle.mp3">Download</a>
<a class="add-music" data-title="Las Bosque" data-artist="" href="audios/song-little.mp3">Add to List</a>
<a class="download-music" href="audios/song-big.mp3">Download</a>
我的代码 jquery 是:
$( document ).ready(function() {
$('.add-music').click(function() {
$.ajax({
'type':'POST',
'data':fuction() {
var songNew = JSON.stringify({
title: $(this).attr('data-title'),
artist: $(this).attr('data-artist'),
mp3: $(this).attr('href'),
});
});
datatype: 'json',
url: 'session.php',
async: true,
cache:false
});
});
});
但它不起作用,有什么办法可以让这个更好更清洁?