Since you are loading in the spans via ajax you will have to attach delegate handlers to the events to catch them as they bubble up.
$(document).on('click','span',function(e){
console.log(e.target.id)
})
you will want to attach the event to the closest static member you can to increase efficiency.
$('#main_div').on('click','span',function(e){
console.log(e.target.id)
})
is better than binding to the document for instance.
This question may help you understand