Código de JQuery - Enviar y Retornar con AJAX // Enviar y Abrir con AJAX

1.0

Publicado el 11 de Julio del 2018gráfica de visualizaciones de la versión: 1.0
3.347 visualizaciones desde el 11 de Julio del 2018
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
 
<script>
$(document).ready(function(){
 
		// evento para cuando se pulse click 
		$("#enviar_recibir").click(function(){
		 $("#res").html( returnAjax('recibe.php', { "envio1": "Alberto", "envio2" : "Maria" , "envio3" : "Jose" }) ) ;
		});
//////////////////   en el archivo php que Envia Y Recibe por AJAX  ///////////////////////////////////////
 
//      <?php
//		  echo '
//       envio1  :  <b>'.$_POST['envio1'].'</b><br>
//       envio2  :  <b>'.$_POST['envio2'].'</b><br>
//       envio3  :  <b>'.$_POST['envio3'].'</b><br>';
//       ?>		
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
		// evento para cuando se pulse click 
		$("#enviar_abrir").click(function(){
            EnvioAjax('recibe.php', { "envio1": "Luis", "envio2" : "Venezuela" , "envio3" : "Daniel" });
		    setTimeout( function(){  location.href="recibe.php";  },200);
		});
//////////////////   en el archivo php que Envia Y Abre por AJAX  ///////////////////////////////////////
 
//      <?php
//       if(!isset($_SESSION)){session_start();}
//	      if (!empty($_POST['envio1'])){$_SESSION['envio1']=$_POST['envio1'];}
//	      if (!empty($_POST['envio2'])){$_SESSION['envio2']=$_POST['envio2'];}
//	      if (!empty($_POST['envio3'])){$_SESSION['envio3']=$_POST['envio3'];}	
//		  echo '
//       envio1  :  <b>'.$_SESSION['envio1'].'</b><br>
//       envio2  :  <b>'.$_SESSION['envio2'].'</b><br>
//       envio3  :  <b>'.$_SESSION['envio3'].'</b><br>';
//       ?>		 <br><button  onclick="javascript:history.back()">Regresar</button>
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////		
});
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////  ESTAS FUNCIONES LAS PODEMOS GRABAR EN UN JS APARTE 
/////////////////////  PARA LUEGO PODER LLAMARLAS LA VECES QUE DESEEMOS EN NUESTRO PROYECTO
function EnvioAjax(url,valores){
      $.ajax({
		    data: valores,
            url: url,
            type: 'post'
      })
}
function returnAjax(url,valores){
      var dev;
      $.ajax({
		    type: 'post',
		    data: valores,
            url: url,
            async: false
      })
      .done(function(data){
            dev = data;
      });
      return (dev);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
</script>
</head>
 
<body>
 
	<button id="enviar_recibir">Enviar Y Recibir por AJAX</button><br />
 
	 <button id="enviar_abrir">Enviar Y Abrir por AJAX</button><br />
 
	<br /><div id="res"></div>
 
</body>
</html>



Comentarios sobre la versión: 1.0 (0)


No hay comentarios
 

Comentar la versión: 1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s4700