I have a AJAX call that finds any elements with the class videoReplace
jQuery('.videoReplace').each(function(index) {
jQuery.ajax({
type: 'post',
url: 'http://optinsmart.com/videos.php',
cache: false,
data:{
'video': jQuery( this ).attr('video-source')
},
dataType: 'html',
success:function(data){
jQuery('#'+jQuery( this ).attr('id')).html(data);
},
error: function(errorThrown){
console.log(errorThrown);
}
});
});
Here is my HTML
<h2>Tanya & Matt Ice Cream</h2>
<div id="tanya" id-name="tanya" class="videoReplace" video-source="Opt-in Smart review by Tanya_Matt Ice cream"></div>
in theory this code should post to my video page and the video playing is sent back in html. Then i want to add the html to the div that im working with.
it tells me that jQuery('#'+jQuery( this ).attr('id'))
is undefinded
Any suggestions?