$('#saveplaylist').click(function () {
var length = $(' .organizer-media').length;
var contents=$(' .organizer-media');
var data = null;
for (var i = 0; i < length; i++) {
data[i] = contents[i].title;
}
$.ajax({
type: 'POST',
data: JSON.stringify(data),
url: '/Builder/Save',
success: function () {
alert("Playlist saved successfully!!");
}
})
})
如上面在我的代码中所示,我无法通过使用 for 循环填充数据数组来发送我的值如何创建数据数组并通过 AJAX 发布它?