Dil*_*dra 4 javascript ajax jquery
我用来更新AJAX成功函数中的Label值,如下所示,但我需要知道我将如何应用此方法来更改/更新"src"的 <img id="myimage" src=""/>
$.ajax({
url: 'clmcontrol_livematchupdate',
type: 'post',
dataType: 'json',
success: function (data) {
$('#mstatus').html(data.matchstatus);
// $('#myimage').... ?
},
complete: function () {
// Schedule the next request when the current one has been completed
setTimeout(ajaxInterval, 4000);
}
});
Run Code Online (Sandbox Code Playgroud)
使用jquery,你可以使用like $("#myimage").attr('src','img url');
假设,你有回应,就像data.imgsrc它应该是的,$("#myimage").attr(src, data.imgsrc);
$.ajax({
url: 'clmcontrol_livematchupdate',
type: 'post',
dataType: 'json',
success: function (data) {
$('#mstatus').html(data.matchstatus);
$("#myimage").attr('src','img url');
},
complete: function () {
// Schedule the next request when the current one has been completed
setTimeout(ajaxInterval, 4000);
}
});
Run Code Online (Sandbox Code Playgroud)