Funcion de botones en Javascrip Como puedo llenar dos tablas con dos botones
Publicado por alexis (11 intervenciones) el 11/07/2019 19:56:33
aqui tengo dos funciones que son llamadas a dos tablas web el problema que tengo es que no llena las 2 solo una la otra muestra errores.
$(document).ready(function () {
//inicio
$("#myButton").click(function () {
$('#simpleTable tbody').empty();
$('#simpleTableSec tbody').empty();
var A = $("#input1").val();
var B = $("#input2").val();
var C = $("#input3").val();
var D = $("#input4").val();
callAjax(A, B, C);
callAjaxSec(D);
});
});
function callAjax(A,B,C) {
$.ajax({
type: "POST",
url: "/App/SecuenciasPickingjson",
data: JSON.stringify({ 'A': A, 'B': B, 'C': C }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
console.log(response);
table(response);
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
}
function table(data) {
var table = $('#simpletable').DataTable();
table.clear();
if (data) {
var json = data;
$(json).each(function (index, pos) {
var a = json[index].Folio;
var b = json[index].PickinId;
var c = json[index].vin;
var d = json[index].Surtido;
var e = json[index].SurtidoFecha;
var f = json[index].CajaId;
var g = json[index].RemisionId;
table.row.add([
a,
b,
c,
d,
e,
f,
g
]).draw(false);
});
}
}
//_______________________________________________________________________________________________
function callAjax(D) {
$.ajax({
type: "POST",
url: "/App/PickingEstatusjson",
data: JSON.stringify({ 'D': D }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
console.log(response);
tableSec(response);
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
}
function tableSec(data) {
var table = $('#simpletableSec').DataTable();
table.clear();
if (data) {
var json = data;
$(json).each(function (index, pos) {
var a = json[index].Folio;
var b = json[index].PickinId;
var c = json[index].vin;
var d = json[index].Surtido;
var e = json[index].SurtidoFecha;
var f = json[index].CajaId;
var g = json[index].RemisionId;
table.row.add([
a,
b,
c,
d,
e,
f,
g
]).draw(false);
});
}
}
$(document).ready(function () {
//inicio
$("#myButton").click(function () {
$('#simpleTable tbody').empty();
$('#simpleTableSec tbody').empty();
var A = $("#input1").val();
var B = $("#input2").val();
var C = $("#input3").val();
var D = $("#input4").val();
callAjax(A, B, C);
callAjaxSec(D);
});
});
function callAjax(A,B,C) {
$.ajax({
type: "POST",
url: "/App/SecuenciasPickingjson",
data: JSON.stringify({ 'A': A, 'B': B, 'C': C }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
console.log(response);
table(response);
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
}
function table(data) {
var table = $('#simpletable').DataTable();
table.clear();
if (data) {
var json = data;
$(json).each(function (index, pos) {
var a = json[index].Folio;
var b = json[index].PickinId;
var c = json[index].vin;
var d = json[index].Surtido;
var e = json[index].SurtidoFecha;
var f = json[index].CajaId;
var g = json[index].RemisionId;
table.row.add([
a,
b,
c,
d,
e,
f,
g
]).draw(false);
});
}
}
//_______________________________________________________________________________________________
function callAjax(D) {
$.ajax({
type: "POST",
url: "/App/PickingEstatusjson",
data: JSON.stringify({ 'D': D }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
console.log(response);
tableSec(response);
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
}
function tableSec(data) {
var table = $('#simpletableSec').DataTable();
table.clear();
if (data) {
var json = data;
$(json).each(function (index, pos) {
var a = json[index].Folio;
var b = json[index].PickinId;
var c = json[index].vin;
var d = json[index].Surtido;
var e = json[index].SurtidoFecha;
var f = json[index].CajaId;
var g = json[index].RemisionId;
table.row.add([
a,
b,
c,
d,
e,
f,
g
]).draw(false);
});
}
}
Valora esta pregunta


0