有没有一种方法可以重新加载一个函数而不是整个页面

Is there a way to reload a function but not the whole page?

本文关键字:函数 一个 新加载 方法 一种 有没有 加载      更新时间:2024-03-23

我有一个从Soundcloud //connect.soundcloud.com/sdk.js 流式传输的图像

var song = 0;
function artwork() {
    $(document).ready(function() {
    SC.get("/users/user/favorites", function(track){
        $('#soundcloudimage').css('background-image', 'url(' + track[song].artwork_url.replace('large', 't500x500') + ')'); 
    });
});

然后我有另一个功能,可以改变从哪个轨道(song)获得艺术品:

function changeSong() {
    song = song + 1;
}

和html:

<div id="soundcloudimage"></div>
<button onclick="changeSong();">Next</button>

但目前,当我点击按钮时,它什么也不做。我认为它需要刷新艺术作品功能,但我希望它在不刷新整个页面的情况下完成这项工作?我该怎么做?

if you want to call the artwork function again:
function changeSong()
{
song = song + 1;
artwork();
}