
ayuda con envio de variable con ajax
Publicado por Marcelino (3 intervenciones) el 07/09/2024 01:19:36
hola a todos tengo este formulario en el cual estoy aplicando unas lineas de codigo AJAX para mandar una variable con el metodo Post a otro formulario de nombre consulta.php, pero no esta mandando dicha a variable. Coloqué el ajax en negrita. Podrian darme una sugerencia? Gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<form name="form1" action="" method="post">
<table align="center" class="bordetbl1">
<tr>
<td class="tit1">Consulta</td></tr>
</table>
<?php
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
$query= pg_query("SELECT max(nrohistoria) as MaxNroHistoria FROM pacientes");
$row = pg_fetch_row($query);
$id = str_pad(trim($row[0]),4,"0",STR_PAD_LEFT);
?>
<table align="center"><tr>
<td class='sr'>Ultimo Nro de Historia:<input type='text' readonly="T" value="<?php echo $id; ?>" name='nrohistoria' size='10' maxlength='10' align='right'class="color1"/></td></tr>
</table>
<table width="200" align="center" class="bordetbl1">
<tr>
<td class="tit1">Nro Historia:</td>
<td><input type="text" name="nrohistoria" id="nrohistoria" size="8"></td>
<td><input type="submit" name="buscar" value="Buscar"></td>
<td> <button type="button" VALUE="Salir" ONCLICK="window.location.href='menu1.php'" class="btn btn-primary">Salir</button></td>
</tr>
</table>
<?php
$nrohistoria = $_POST['nrohistoria'];
if($nrohistoria && $_POST['buscar'])
{
$query="SELECT nrohistoria FROM public.pacientes WHERE nrohistoria='$nrohistoria'";
$res=@pg_query($connect,$query);
if(@pg_num_rows($res)>0)
{
?>
<script type='text/javascript'>
var agree=confirm("El paciente Ya posee historia médica, ¿Desea Crear una consulta?");
if (agree)
$.ajax({
url: 'consulta.php',
type: 'POST',
data: {nro: <?php echo $nrohistoria; ?> },
});
else
window.location='pacientes.php';
</script>
<?php
}
else
{
?>
<script type='text/javascript'>
var agree=confirm('El Número de HISTORIA no esta Registrado Debe registrarse con la Cedula del Representante');
if (agree)
window.location='pacientes2.php?nro=<?php echo $nrohistoria?>';
else
window.location='pacientes.php';
</script>
<?php
}
}
?>
</table>
<br>
<br>
</form>
Valora esta pregunta


0