I have a button that calls a JS function, but I have not been able to send more than one parameter
$("#msgPrueba").html('<script>$("#exampleModalx").modal({backdrop: "", keyboard: false});</script><div class="modal fade" id="exampleModalx" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">' +
'<div class="modal-dialog" role="document">'+
'<div class="modal-content">'+
'<div class="modal-header">'+
'<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>'+
'<h4 class="modal-title" id="exampleModalLabel">
<span style="font-size:14px">:: Factura '+ factura +' ;;</style>' +
'</div>'+
'<div class="modal-body">'+
'<center><img src="../Images/ok.jpg" width="70px" height="60px"/><br/>"' + data + '"</center>' +
'<center><img src="../Images/ok.png" width="30px" height="30px"/><br/><br/>' + data + '<br/><span style="font-size:12px;color:green">Serie(s) guardada(s) exitosamente</span></center>'+
'</div>'+
'<div class="modal-footer">'+
'<button type="button" class="btn btn-default" id="btnCerrarModal" onClick="facturaSer( "' + factura + '","SI")" data-dismiss="modal">Cerrar</button>' +
'</div>'+
'</div>'+
'</div>'+
'</div>');
and my function is
function facturaSer(varfactura, varplazos) {
alert(varplazos);
var fact = varfactura
//alert(fact);
var cargando = $("#muestraSeccion").html("<center><img src='../Images/cargando1.gif' height='50px' width='50px'/><br/>Un momento por favor...<center>");
$.ajax({
type: 'POST',
url: 'buscaFactura',
data: {
"factura": fact
},
success: function (resultado) {
//cargando.hide();
$("#muestraSeccion").hide().html(resultado).fadeIn("fast");
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR, textStatus, errorThrown);
if (jqXHR.status === 0) {
alert('Not connect: Verify Network.=(');
} else if (jqXHR.status == 404) {
alert('Requested page not found [404].');
} else if (jqXHR.status == 500) {
alert('Error Interno del Servidor [500].');
} else if (textStatus === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (textStatus === 'timeout') {
alert('Time out error.');
} else if (textStatus === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error: ' + jqXHR.responseText);
}
}
});
}
and I get an error VM540 inicioEmpresariales:2 Uncaught SyntaxError: Unexpected token }
, am I calling the function correctly?
You have several errors in the JS, such as tags that are not closed, problems with the quotes in the close button, lack of ; in "var fac = ..." for concatenating double quotes you must use \", also how are you creating a script tag must be closed with </script> otherwise the browser does not correctly interpret the script