Ajax e PHP
Olá
eu estou com a sequinte dificuldade, eu tenho um arquivo javascript que deveria melhorar o processo de login.
login.js -> Dentro da pasta Ajax
var isIE;
var req; //variavel de requisição
function initRequest() {
if (window.XMLHttpRequest) {
if (navigator.userAgent.indexOf('MSIE') != -1) {
isIE = true;
}
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
isIE = true;
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
function sendLogin() {
var login = document.getElementById("login");
var senha = document.getElementById("senha");
var script = "../Processos Publicos/Processos para Visitantes/login.php";
var ajax = initRequest();
ajax.open("POST", script, true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) {
alert(ajax.responseText);
alert(script);
}
}
var valores = "login="+login+"&senha="+senha;
ajax.send(valores);
}
login.php -> diretorio a partir do raiz (Processos Publicos/Processos para Visitantes/)
<?php
//arquivo de teste de ajax
$senha = $_POST['senha'];
$usuario = $_POST['login'];
echo $senha.$usuario;
?>
Arquivo html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="Ajax/login.js" type="text/javascript"></script>
</head>
<body>
<form name="login" action="#" method="POST" onSubmit="sendLogin()">
<input type="text" name="login" value="" />
<input type="text" name="senha" value="" />
<input type="submit" value="enviar" name="send" />
</form>
</body>
</html>
bem, vocês vem algum erro? porque o response text aparece nulo?
desde já grato.
Ningem conseque me ajudar?
Discussão (1)
Carregando comentários...