Vereis tengo una funcion y la quiero llamar desde el dentro las etiquetas javascritp nada especial la cosa es que no se por que no está funcionado, esta es la funcion y la llamada enviarFormulario() :
Código Javascript:
Ver original
function nuevoAjax(){ var xmlhttp=false; try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) {xmlhttp = false;}} if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest();} return xmlhttp; } enviarFormulario("comparativas_select.php", "formulario_1", "resultado"); enviarFormulario("comparativas_select.php", "formulario_2", "resultado2"); function enviarFormulario(url, formid, divrespuesta){ var Formulario = document.getElementById(formid); var longitudFormulario = Formulario.elements.length; var cadenaFormulario=""; for (var i=0; i <= Formulario.elements.length-1;i++) { if(Formulario.elements[i].type=="checkbox" || Formulario.elements[i].type=="radio"){ if(Formulario.elements[i].checked==true){cadenaFormulario += "&"+Formulario.elements[i].name+'='+encodeURIComponent(Formulario.elements[i].value);} }else{cadenaFormulario += "&"+Formulario.elements[i].name+'='+encodeURIComponent(Formulario.elements[i].value);} } alert('buena'); peticion=nuevoAjax(); peticion.open("POST", url, true); peticion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); peticion.send(cadenaFormulario); peticion.onreadystatechange = function() { if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){ RESPUESTA=peticion.responseText; document.getElementById(divrespuesta).innerHTML =RESPUESTA; } if (peticion.readyState == 4 && peticion.status != 200){ document.getElementById(divrespuesta)="FALLA EN LA COMUNICACION... SI EL PROBLEMA CONTINUA, FAVOR DE REPORTARLO"; } } if(divrespuesta == 'resultado'){ peticion0=nuevoAjax(); peticion0.open("POST", "comparativas_info1.php", true); peticion0.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); peticion0.send(cadenaFormulario); peticion0.onreadystatechange = function() { if (peticion0.readyState == 4 && (peticion0.status == 200 || window.location.href.indexOf ("http") == - 1)){ RESPUESTA0=peticion0.responseText; document.getElementById("resultado1").innerHTML =RESPUESTA0; } if (peticion0.readyState == 4 && peticion0.status != 200){ document.getElementById("resultado1")="FALLA EN LA COMUNICACION... SI EL PROBLEMA CONTINUA, FAVOR DE REPORTARLO"; } } } if(divrespuesta == 'resultado2'){ peticion1=nuevoAjax(); peticion1.open("POST", "comparativas_info2.php", true); peticion1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); peticion1.send(cadenaFormulario); peticion1.onreadystatechange = function() { if (peticion1.readyState == 4 && (peticion1.status == 200 || window.location.href.indexOf ("http") == - 1)){ RESPUESTA1=peticion1.responseText; document.getElementById("resultado22").innerHTML =RESPUESTA1; } if (peticion1.readyState == 4 && peticion1.status != 200){ document.getElementById("resultado22")="FALLA EN LA COMUNICACION... SI EL PROBLEMA CONTINUA, FAVOR DE REPORTARLO"; } } } }
A ver si alguien sabe por que, un saludo.