Hola como les va, vuelvo con mis problemillas en ajax cosa que nuevamente no logro ver su Error.
Lo que hice es un formulario algo simple, paso este por ajax llegando a php...
pero el tema es que no me envia ni me informa de los estados ( onreadystatechange )
EL PHP , SI LO ABRO EN EL NAVEGADOR CON LAS VARIABLES FUNCIONA POR ENDE EL ERROR ESTA EN JS
Código HTML:
Ver original<form onSubmit="Enviar();"> <? include("Select.php"); ?>
<input type="text" id="Titulo" placeholder="Ingresa el nombre del disco" /><br> <input type="url" id="Imagen" placeholder="Ingresa la url de la caratula"/><br> <input type="number" id="Ano" placeholder="Año" /><br> <input type="number" id="Velocidad" placeholder="Velocidad" /><br> <input type="text" id="Servidor" placeholder="Ej:Megaupload,rapidshare..."/><br> <input type="text" id="Sello" placeholder="El sello discografico" /><br> <input type="url" id="Descarga" placeholder="El link de descarga"/> <Estados id="Estados"></Estados>
<input type="submit" name="Enviar" value="Enviar"/> <input type="button" onClick="Previsualizar(); return true;" value="Previsualizar" />
Código Javascript
:
Ver originalfunction Enviar(){
var id = document.getElementById('Interprete').value;
var Interprete1 = document.getElementById('Interprete').selectedIndex;
var Interprete = document.getElementById('Interprete').options[Interprete1].text;
var Titulo = document.getElementById('Titulo').value;
var Ano = document.getElementById('Ano').value;
var Velocidad = document.getElementById('Velocidad').value;
var Servidor = document.getElementById('Servidor').value;
var Sello = document.getElementById('Sello').value;
var Descarga = document.getElementById('Descarga').value;
var Imagen = document.getElementById('Imagen').value;
// --- Variables ajax
var ajax = new XMLHttpRequest();
/* Estados */
ajax.onreadystatechange=function(){
/* Si se esta cargando */
if(ajax.readyState==1 || ajax.readyState==2 || ajax.readyState==3){
document.getElementById('Estados').innerHTML='Procesando su peticion...';
}
/* Si se cargo */
if(ajax.readyState==4 && ajax.status==200){
document.getElementById('Estados').innerHTML=ajax.responseText;
}
}
// --- Envios---
ajax.open("POST","Enviar.php?id="+id+"&Interprete="+Interprete+"&Titulo="+Titulo+"&Ano="+Ano+"&Velocidad="+Velocidad+"&Servidor="+Servidor+"&Sello="+Sello+"&Descarga="+Descarga+"&Imagen="+Imagen,true);
ajax.send();
}
Código PHP:
Ver original<?
// --- Conexion mysql ---
// --- Variables ---
$Id = $_GET['id'];
$Interprete = $_GET['Interprete'];
$Titulo = $_GET['Titulo'];
$Ano = $_GET['Ano'];
$Imagen = $_GET['Imagen'];
$Velocidad = $_GET['Velocidad'];
$Servidor = $_GET['Servidor'];
$Sello = $_GET['Sello'];
$Descarga = $_GET['Descarga'];
// --- Insercion mysql ---
$Envio = mysql_query("INSERT INTO album (indentificador,id,Interprete,Imagen,Titulo,Ano,Velocidad,Servidor,Sello,Descarga, Usuarios,Valores,Megusta) VALUES ('','".$Id."','".$Interprete."', '".$Imagen."','".$Titulo."', '".$Ano."', '".$Velocidad."', '".$Servidor."', '".$Sello."', '".$Descarga."', '0', '0', '1');");
// --- Si Esta bien el envio ---
if($Envio){
echo 'El album se acabo de crear vease';
}
// --- Cerrando mysql ---