Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/09/2015, 14:00
lubtufano
 
Fecha de Ingreso: julio-2011
Mensajes: 220
Antigüedad: 12 años, 9 meses
Puntos: 72
Respuesta: Duda sobre ajax , jquery

¿Dónde está la función showCustomer? La que muestras en el código es showUser, suponiendo que esa es, sí se puede usar con ambos botones sólo habría que agregar otro div para mostrar la segunda lista y elegir entre uno y otro, según el parámetro recibido, en la función asociada al evento onreadystatechange.
Código Javascript:
Ver original
  1. xmlhttp.onreadystatechange = function() {
  2.   if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {
  3.     if (str == 1) {
  4.       document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
  5.     } else {
  6.       document.getElementById("txtHint2").innerHTML = xmlhttp.responseText;
  7.     }
  8.   }
  9. }
  10.  
  11. <div id="txtHint"><p>Person info will be listed here...</p></div>
  12. <div id="txtHint2"><p>Person info will be listed here...</p></div>

Obviamente también se debería modificar el archivo .php que recibe la petición para que retorne la información correspondiente a la variable que se envía.

if($_GET["q"] == 1) {
//cosulta para fútbol
} elseif($_GET["q"] == 2) {
//cosulta para baloncesto
}