Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/02/2016, 13:23
sanandresm
 
Fecha de Ingreso: diciembre-2015
Mensajes: 67
Antigüedad: 8 años, 4 meses
Puntos: 2
Respuesta: Javascript para ejecutar PHP (que guarda datos)

Yo te dare codigo:

PHP:
Código PHP:
Ver original
  1. <?php
  2.     $dats = json_decode($_REQUEST["d"], true);
  3.     // la variable $dats queda con el array que enviamos
  4. ?>

JavaScript:
Código Javascript:
Ver original
  1. dats = JSON.stringify(ARRAY_A_ENVIAR);
  2.     var xmlHttp;
  3.     try
  4.     {
  5.         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  6.     }
  7.     catch(e)
  8.     {
  9.         try
  10.         {
  11.              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  12.         }
  13.         catch(oc)
  14.     }
  15.     if(!xmlHttp && typeof XMLHttpRequest != "undefined")
  16.     {
  17.         xmlHttp = new XMLHttpRequest();
  18.     }
  19.     var ajaxRequest = 'script.php?d=' + dats;
  20.     xmlHttp.open("GET", ajaxRequest, true);
  21.     xmlHttp.send(null);

Obviamente script.php es el nombre del archivo en php