I have a code in which I check if the client in an input was introduced. If so, if this checking account is checked, write it down and it is because it was charged on the spot.
But first I have a conditional, where if the client code has not been introduced do not do anything.
$("#canilla1").click(function(event) {
$("input[value=Confirmar]").click(function(){
var id = $(this).attr("id");
var cliente = $("#codcli").val();
if (cliente!==""){
if ($("#cc").attr("checked",false)){
pago="s";
$.ajax({
type: "POST",
url: "../gestionweb/views/modules/venta/procesoventa.php",
data:{"accion":"cc","cliente":cliente,"idpg":id,"fecha":fecha,"hora":hora,"pago":pago},
error: function(){
alert("error petición ajax");
},
success:function(data)
{
window.location.href="index.php?controller=venta&action=index";
}
});
} else if ($("#cc").attr("checked")){
pago="n";
$.ajax({
type: "POST",
url: "../gestionweb/views/modules/venta/procesoventa.php",
data:{"accion":"cc","cliente":cliente,"idpg":id,"fecha":fecha,"hora":hora,"pago":pago},
error: function(){
alert("error petición ajax");
},
success:function(data)
{
window.location.href="index.php?controller=venta&action=index";
}
});
} }else {alert("ingrese el cliente");}
});});
But the fact is that it executes the ajax queries in the same way.