,의 말을하자jQuery를 POST 아약스 요청
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Naamloos document</title>
</head>
<body>
<form id="Form" onsubmit="validate();" method="post">
Email Address: <input type="text" id="email" name="email">
Password: <input type="text" id="password" name="password">
<input type="submit">
</form>
<script>
function validate()
{
var e = $('email').value;
var p = $('password').value; //jQuery is easier to type
// the same as
// var p = document.getElementById('password').value;
var req = new Request({
url: 'http://www.B.com/validate.php?',
method: 'post',
data: {'email' : e, 'password' : p},
onComplete: function(response)
{
if (response == "Valid")
{
alert("succes");
}
else
{
alert("blur");
}
}
}).send();
}
</script>
</body>
</html>
을하지만,이 순간에, 제출 버튼을 눌렀을 후, happends 유일한 것은, 필드가 삭제되고 있다는 모든 이잖아 : 같은,이 스크립트는 서버 A에서 실행됩니다.
Validate.php은 다음과 같습니다 : 자바 스크립트 결코 큰 아무것도 할 수있는 기회를 얻을 수 없다, 그래서 당신은 양식을 제출하고
<?php echo "Valid"; ?>
으로이
을 대체하려고? – Oxi
요청에'onError' 핸들러를 추가하십시오. 'console.log (response)'를 사용하여 콘솔에 응답을 기록하십시오. –
그리고'Request' 클래스가 무엇인지 알려주세요. 잘 모르겠습니다. –