I want to display my ship registration number from the database in an AJAX response. I am using a method to send my field and then show the ship registration number in another function. Here is the code snippet that I have debugged: show_name(2d1c9a7158625608);
<script>
function show_new_chat(){
var param_obj = {action: 'voyage/find_all_ship_voyage'}
var qs = decodeURIComponent($.param(param_obj));
$.ajax({
type: "get",
url: 'transport/',
data: $(this).serialize() + '&' + qs,
dataType: 'json',
success:function(res)
{
var str = '<div>';
if (res.data != 0) {
$.each(res.data, function(k, v) {
str += '<ul>';
str += '<button type="button" onclick="show_name('+v.ship_reg_num+');" id="'+v.ship_reg_num+'" style="text-decoration: none; background-color: transparent;" >'+v.ship_name+'</button>';
str += '</li>';
str += '</ul>';
str += '<hr>';
});
}
str +='</div>';
$('#list-contact').html(str);
},
error: function (jqXHR, status, err) {
// alert('Local error callback');
}
});
}
function show_name(ship_reg_num){
}
</script>