Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Problema Con Formulario en ajax

Estas en el tema de Problema Con Formulario en ajax en el foro de Frameworks JS en Foros del Web. Holas de nuevo tengo un problemita con un form, tengo dos campos de texto llamados op1 y op2 pero cuando le doy enviar al form, ...
  #1 (permalink)  
Antiguo 21/08/2008, 11:59
Avatar de yuguilley  
Fecha de Ingreso: febrero-2004
Ubicación: Montenegro Quindío
Mensajes: 108
Antigüedad: 20 años, 2 meses
Puntos: 0
Problema Con Formulario en ajax

Holas de nuevo

tengo un problemita con un form,

tengo dos campos de texto llamados
op1 y op2

pero cuando le doy enviar al form, solo me esta capturando el primer campo (op1).

me ayuda porfa a ver que tengo mal?

Código PHP:
var time_variable;
 
function 
getXMLObject()  //XML OBJECT
{
   var 
xmlHttp false;
   try {
     
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   
}
   catch (
e) {
     try {
       
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     
}
     catch (
e2) {
       
xmlHttp false   // No Browser accepts the XMLHTTP Object then false
     
}
   }
   if (!
xmlHttp && typeof XMLHttpRequest != 'undefined') {
     
xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   
}
   return 
xmlHttp;  // Mandatory Statement returning the ajax object created
}
 
var 
xmlhttp = new getXMLObject();    //xmlhttp holds the ajax object
 
function ajaxFunction() {
  var 
getdate = new Date();  //Used to prevent caching during ajax call
  
if(xmlhttp) { 
      var 
op1 document.getElementById("op1");
    var 
op2 document.getElementById("op2");
    
xmlhttp.open("POST","post.php",true); //calling testing.php using POST method
    
xmlhttp.onreadystatechange  handleServerResponse;
    
xmlhttp.setRequestHeader('Content-Type''application/x-www-form-urlencoded');
    
xmlhttp.send("op1=" op1.value);
    
xmlhttp.send("op2=" op2.value); //Posting txtname to PHP File
  
}
}
 
function 
handleServerResponse() {
   if (
xmlhttp.readyState == 4) {
     if(
xmlhttp.status == 200) {
       
document.getElementById("message").innerHTML=xmlhttp.responseText//Update the HTML Form element 
     
}
     else {
        
alert("Error during AJAX call. Please try again");
     }
   }

  #2 (permalink)  
Antiguo 21/08/2008, 13:22
Avatar de foreverOdd  
Fecha de Ingreso: noviembre-2007
Ubicación: Caracas
Mensajes: 489
Antigüedad: 16 años, 5 meses
Puntos: 14
Respuesta: Problema Con Formulario en ajax

xmlhttp.send("op1=" + op1.value);
xmlhttp.send("op2=" + op2.value); //Posting txtname to PHP File

cambialo por:

xmlhttp.send("op1=" + op1.value+"&op2="+ op2.value);
__________________
My path is lit by my own fire, I only go where I desire
  #3 (permalink)  
Antiguo 21/08/2008, 13:28
Avatar de yuguilley  
Fecha de Ingreso: febrero-2004
Ubicación: Montenegro Quindío
Mensajes: 108
Antigüedad: 20 años, 2 meses
Puntos: 0
Respuesta: Problema Con Formulario en ajax

Gracias Colega, me funciona perfecto
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:27.