0
I have table made in Javascript, follow the image below:
Follow the Javascript code (Code is working perfectly):
$(".js-tbody-historico-cliente").on("change", function() {
var codigo_cliente = $(codigoCliente).val();
var tipo_busca = $(tipoBusca).val();
$
.ajax({
type: "GET",
url: "/buscahistoricocliente",
data: ({
codigoCliente: codigo_cliente,
tipoBusca: tipo_busca
}),
dataType: 'json',
success: function(data) {
var text = "";
text += "<thead><tr>" +
"<th class='text-center col-lg-1'>" + data[0][0] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][1] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][2] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][3] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][4] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][5] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][6] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][7] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][8] + "</th>" +
"</thead>";
for (i = 1; i < data.length; i++) {
text += "<tbody><tr>" +
"<td>" + data[i][1] + "</td>" +
"<td>" + data[i][4] + "</td>" +
"<td>" + data[i][5] + "</td>" +
"<td>" + data[i][6] + "</td>" +
"<td>" + data[i][7] + "</td>" +
"<td>" + data[i][8] + "</td>" +
"<td>" + data[i][9] + "</td>" +
"<td>" + data[i][10] + "</td>" +
"<td>" + data[i][11] + "</td>" +
"</tr></tbody>";
}
$("#js-tbody-historico-venda-cliente").html(text);
$("#graficosCliente").show();
}
});
});
Only instead of appearing the product code in the product column (as the image sent) I need to appear image of this product.
I put This way, but I did something wrong and I would like the help of colleagues because I have no experience with Js.
$(".js-tbody-historico-cliente").on("change", function() {
var codigo_cliente = $(codigoCliente).val();
var tipo_busca = $(tipoBusca).val();
$
.ajax({
type: "GET",
url: "/buscahistoricocliente",
data: ({
codigoCliente: codigo_cliente,
tipoBusca: tipo_busca
}),
dataType: 'json',
success: function(data) {
var text = "";
text += "<thead><tr>" +
if(data[0][0] == 'BS56EF'){
"<th class='text-center col-lg-1'> <img src="BS56EF"/></th>" +
}
if(data[0][0] == 'FP56EA'){
"<th class='text-center col-lg-1'> <img src="FP56EA"/></th>" +
}
if(data[0][0] == 'FS56EB'){
"<th class='text-center col-lg-1'> <img src="FS56EB"/></th>" +
}
if(data[0][0] == 'FS56EB'){
"<th class='text-center col-lg-1'> <img src="FS56EB"/></th>" +
}
"<th class='text-center col-lg-1'>" + data[0][1] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][2] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][3] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][4] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][5] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][6] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][7] + "</th>" +
"<th class='text-center col-lg-1'>" + data[0][8] + "</th>" +
"</thead>";
for (i = 1; i < data.length; i++) {
text += "<tbody><tr>" +
"<td>" + data[i][1] + "</td>" +
"<td>" + data[i][4] + "</td>" +
"<td>" + data[i][5] + "</td>" +
"<td>" + data[i][6] + "</td>" +
"<td>" + data[i][7] + "</td>" +
"<td>" + data[i][8] + "</td>" +
"<td>" + data[i][9] + "</td>" +
"<td>" + data[i][10] + "</td>" +
"<td>" + data[i][11] + "</td>" +
"</tr></tbody>";
}
$("#js-tbody-historico-venda-cliente").html(text);
$("#graficosCliente").show();
}
});
});
The error you present is Required String Parameter 'parametroBuscaClient' is not present
It’s not the solution to your mistake, but you messed up a little bit in time to do the
src
images. Use single quotes in the javascript string, and then use double quotes around thesrc
image. And don’t forget to put the file extension. Example:'<th class="text-center col-lg-1"> <img src="FS56EB.jpg"/></th>'
– Máttheus Spoo
Thanks for the help and explanation, I put the code as Paz commented below and now I will look for why the error occurs in Back. I appreciate the help.
– Joyce SD