Jquery 从ajax响应更新类
我想用ajax调用的响应更新类,但只更新特定实例Jquery 从ajax响应更新类,jquery,ajax,Jquery,Ajax,我想用ajax调用的响应更新类,但只更新特定实例 audiojs.events.ready(function() { var as = audiojs.createAll(); jQuery(as).ready(function($) { $('.ca_podcast_file').each(function(){ /* cache the container instance in a variable*/ v
audiojs.events.ready(function() {
var as = audiojs.createAll();
jQuery(as).ready(function($) {
$('.ca_podcast_file').each(function(){
/* cache the container instance in a variable*/
var $container=$(this);
/* searching within the container instance for each
component insulates multiple instances on page*/
var $audio= $container.find('audio');
/*now events will only be bound to this instance*/
$audio.on('playing',function(){
/* within event callbacks keep searches within the main container element*/
var fileID=$audio.attr('id');
var data = {file_id: fileID ,security:ChurchAdminAjax.security};
jQuery.post(ChurchAdminAjax.ajaxurl, { 'action': 'ca_mp3_action','data': data },
function(response){
$($container,'.plays').html(response);
}
);
});
});
});
});
Html标记
<div class="ca_podcast_file">
<h3>Hearing God</h3>
<p><audio class="sermonmp3" id="54" src="http://www.thegatewaychurch.info/wp-content/uploads/sermons/sermon2013-10-27.mp3" preload="none"/></p>
<p><a href="http://www.thegatewaychurch.info/wp-content/uploads/sermons/sermon2013-10-27.mp3" title="Hearing God">Hearing God</a></a> <br/>
Mike Bollinger prophecies over some people and then helps to get going in hearing for God for ourselves <br/>
<span style="font-size:smaller">The Gateway Church: Mike Bollinger</span>
Played: <div class="plays">16</div> times</p>
</div>
我不知道如何更新该音频实例的播放次数
我怎样才能让它工作呢?原来id是用于音频标签的,不包括plays类。已修改以包含id 然后将html响应行更改为
$('.plays'+fileID).html(响应) 您能显示HTML标记吗?“特定实例”?多解释
$($container,'.plays').html(response);