Este es el .js
Código :
$(document).ready(function(){ function error(){ $(function() { $( "#dialog:ui-dialog" ).dialog( "destroy" ); $( "#error" ).dialog({ buttons:{ OK: function() { $( this ).dialog( "close" ); } }, resizable: false, height: 280, width: 600, modal: true }); return false; }); } function cliente(){ $(function() { $( "#dialog:ui-dialog" ).dialog( "destroy" ); $( "#cliente" ).dialog({ buttons:{ OK: function() { $( this ).dialog( "close" ); } }, resizable: false, height: 280, width: 600, modal: true }); return false; }); } function formu(){ $(function() { $( "#dialog:ui-dialog" ).dialog( "destroy" ); $( "#formu" ).dialog({ buttons:{ OK: function() { $( this ).dialog( "close" ); } }, resizable: false, height: 280, width: 600, modal: true }); return false; }); } function des(){ $(function() { $( "#dialog:ui-dialog" ).dialog( "destroy" ); $( "#des" ).dialog({ buttons:{ OK: function() { $( this ).dialog( "close" ); } }, resizable: false, height: 280, width: 600, modal: true }); return false; }); } $("#crear").click(function(){ if($("#tx2c").val() == false){ error(); return false; } else { var misId = { "nombre" : $("#tx2c").val() }; $.ajax({ data: misId, url: "admin/rtcliente.php", type: "post", success: function(datos){ if(datos=="cliente"){cliente();} else { $("#tx5c").val(datos); $("#puno").hide('fold',600); $("#pdos").show('fold',600); } } }); } }); //fin boton $("#creard").click(function(){ if($("#tx4c").val() == false){ formu(); return false; } if($("#tx5c").val() == false){ formu(); return false; } else { var datos= { "descuento" : $("#tx4c").val(), "idser" : $("#tx3c").val(), "idtipo" : $("#tx5c").val() }; $.ajax({ data: datos, url: "admin/rtcliented.php", type: "post", success: function(texto){ if(texto == "des"){des();} } }); } }); //Fin Jquery });
1er php
Código :
<?php require('../session.php'); if ($_SESSION['tipo'] != "Admin" ){ session_destroy(); header('Location: ../index.html'); exit(); } $nom=$_POST['nombre']; //If Principal if( isset($_POST['nombre']) ) { $bu_serv="CALL bu_tipo_clientes('".$nom."')"; include("../conexion.php"); $consulta=mysql_query($bu_serv,$conexion) or die ("Error".mysql_error()); $resultado=mysql_num_rows($consulta); mysql_close($conexion); //if resultado if ($resultado == 1) { echo ("cliente"); } //fin if resultado //else resultado else { include("../conexion.php"); $pro="CALL in_tipos_clientes('".$nom."','".$_SESSION['ide']."')"; mysql_query($pro,$conexion) or die ("Error: ".mysql_error()); mysql_close($conexion); include("../conexion.php"); $bu_tip="CALL bu_tipo_clientes('".$nom."')"; $con=mysql_query($bu_tip,$conexion) or die ("Error".mysql_error()); $arreglo=mysql_fetch_array($con); $idn= $arreglo['id_tipo']; mysql_close($conexion); echo($idn); } //fin else resultado } //fin If principal //Else Principal else { header('Location: ../admin.html'); } //Fin else Principal ?>
2do. php
Código :
<?php require('../session.php'); if ($_SESSION['tipo'] != "Admin" ){ session_destroy(); header('Location: ../index.html'); exit(); } $servicio=$_POST['idser']; $descuento=$_POST['descuento']; $tipousu=$_POST['idtipo']; //If Principal if( isset($_POST['idtipo']) ) { $budes="CALL co_descuentos_ids('".$servicio."','".$tipousu."')"; include("../conexion.php"); $consulta=mysql_query($budes,$conexion) or die ("Error".mysql_error()); $resultado=mysql_num_rows($consulta); $arreglo=mysql_fetch_array($consulta); $idn= $arreglo['id_descuentos']; mysql_close($conexion); if($resultado == 1) { $indes="CALL ac_descuentos('".$tipousu."','".$servicio."','".$descuento."','".$idn."')"; include("../conexion.php"); $consulta=mysql_query($indes,$conexion) or die ("Error".mysql_error()); mysql_close($conexion); echo("des"); } else { $indes="CALL in_descuentos('".$tipousu."','".$servicio."','".$descuento."')"; include("../conexion.php"); $consulta=mysql_query($indes,$conexion) or die ("Error".mysql_error()); mysql_close($conexion); echo("des"); } } //fin If principal //Else Principal else { header('Location: ../admin.html'); } //Fin else Principal ?>
los 2 ajax se ejecutan 2 veces, ojala y me puedan ayudar,