My code doesn't show errors, but also doesn't work as it should. The output from the ajax call is working fine but I just can't get anything out of the onClick
, no errors message, nothing.
The HTML
<div id="serials"></div>
<div id="accounts_info_key" style="text-align:left"></div>
The Ajax call
$(document).ready(function() {
$('.tab2').click(function(){
var account_id = $('#account_id').val();
$.ajax({
url: 'ajax/account_info_serials_ajax.php',
type:'POST',
dataType: 'json',
data: 'account_id='+account_id,
success: function(response){
$('#serials').html(response.table),
$('#accounts_info_key').html(response.key),
$('.drop_down').hide();
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
} // End of success function of ajax form
}); //end of ajax
});//close trigger
});//close whole function
The PHP
$response = '';
$response .='<div class="question">';
$response .='plop';
$response .='</div>';
$response .='<div class="drop_down">';
$response .='bob';
$response .='</div>';
$output_array = array(
'table' => $response,
'key' => $key,
'count' => $count
);
echo json_encode($output_array);
The jquery onclick
$(document).ready(function() {
$('#serials').on("click", ".question", function(e){
alert('smeg');
});
});
Please note, I am not asking how to do it, I am asking why my version is not working, it is NOT a duplicate question