내 Ajax 코드가 통과하지 않는 문제가 있습니다. 함수가 비어있는 것처럼 말입니다. 나는 아무 일도 발생하지 않습니다 .. 제출을 클릭 AJAX 버튼이 전송되지 않고 통과하지 않습니다.
내 HTML 코드 :<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<body>
<form method="POST" id="contactForm" >
<input type="text" name="email" id="email"></input>
<input type="submit" name="submit"></input>
</form>
<script type="text/javascript">
$('#contactForm').submit(function(e){
e.preventDefault();
var email = $('#email').val();
$.ajax({
type: 'POST',
dataType: 'JSON',
url: 'check.php',
data: {email: email},
success: function(data){
if(data.status == 'success') {
alert('The e-mail address entered is correct.');
} else {
alert('The e-mail address entered is Incorrect.');
}
}
});
});
</script>
</body>
</head>
내 check.php : 내가 원하는
<?php
if (isset($_POST['email'])) {
$status = 'success'
} else {
$status = 'failed';
}
echo json_encode(array('status' => $status));
?>
내가 제출을 클릭하면, 그냥 아무것도하지 않고 .. 오류가 나타납니다.
내가 빠진 것이 있습니까?
잘못된 폐쇄로 인해 스크립트 오류가 발생했습니다. 'else if'가 부정확하고 "success"콜백이 빠진 후에 괄호를 확인하십시오 : –
name = "submit"은 아니오입니다. – wwwmarty
@ MartyMcKeever, 그럼 내가 isset post에 전화하고 싶으면 그걸 필요로 할거야? 아니? – JayVicious