我用来更新AJAX成功函数中的Label值,如下所示,但是我需要知道如何应用此方法来更改/更新广告的“ src” <img id="myimage" 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); } });
使用jQuery,您可以使用像 $("#myimage").attr('src','img url');
$("#myimage").attr('src','img url');
假设您的回应data.imgsrc是这样的,$("#myimage").attr(src, data.imgsrc);
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); } });