Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/03/2011, 21:55
Avatar de El_Metallick
El_Metallick
 
Fecha de Ingreso: noviembre-2002
Ubicación: Santiago, Chile
Mensajes: 1.718
Antigüedad: 21 años, 5 meses
Puntos: 16
Respuesta: Ayuda para desarrollar aplicacion sencilla en ajax y mysql

mmm bueno como sabes php y mysql te daré sólo la parte de ajax

Código Javascript:
Ver original
  1. function newAjax() {
  2.     var xmlhttp = false;
  3.    
  4.     try {
  5.         xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
  6.     } catch(e) {
  7.         try {
  8.             xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
  9.         } catch(E) {
  10.             if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  11.                 xmlhttp = new XMLHttpRequest();
  12.             }
  13.         }
  14.     }
  15.    
  16.     return xmlhttp;
  17. }
  18.  
  19. function searchImage() {
  20.     var code = document.getElemetById('code').value;
  21.     var content = docuemt.getElementById('content');
  22.    
  23.     ajax.open('POST', 'searchImage.php?', true);
  24.     ajax.onreadystatechange = function() {
  25.         if (ajax.readyState == 4) {
  26.             content.innerHTML = ajax.responseText;
  27.         }
  28.     }
  29.    
  30.     ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
  31.     ajax.send('code='+code);
  32. }

En el HTML algo así:

Código HTML:
Ver original
  1. <form action="#" onSubmit="javascript: searchImage();">
  2. Código: <input type="text" id="code" name="code" />
  3. <br /><input type="submit" value="Enviar" />
  4. </form>
  5. <p id="content"></p>

Consideraciones:

la página searchImage.php debe tener:

un $variable = $_POST['code']; para rescatar el código ingresado y hacer la consulta
y en caso de haber una imagen guardada retornar el html de la imágen, es decir algo de la forma

<img src="<?= $foto ?>" />

y con eso debería funcionar, si no me avisas y le hecho una mirada

Saludos
__________________
Haz la guerra en la cama y el amor donde se te de la gana...
El tiempo es el mejor maestro, lo único malo es que te mata...¡¡Aprovecha tu tiempo!!