Ajax 요청이 응답을 다시Ajax 요청은
jQuery 코드 줄이 너무 오래 걸리는 너무 오래 복용 :
<script type="text/javascript">
$(document).ready(function() {
$('#contactForm').on('submit', function(e) {
e.preventDefault();
$.ajax({
type:"POST",
url:"<?php echo site_url;?>includes/listContact.php",
data:$("#contactForm input").serialize(),//only input
success: function(response){
$('#thankMsg').show();
$('#hidediv1').hide();
}
});
});
});
</script>
을이 아약스 코드에 의해 요청 된 페이지입니다 :
$file3 = file_get_contents('a.txt', true);
$data3=json_decode($file3,true);
$to=$data3['email'];
$subject="*********************";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: <'.$to.'>' . "\r\n";
$message="Hi, <br/><br/>";
$message .="*********************** <br/><br/>";
foreach($_POST as $key => $value){
$message .="<strong>".ucfirst(str_replace('_',' ',$key)).":</strong> $value<br/>";
}
$message .="<br/><br/><strong>Thanks</strong><br/>";
if(mail ("$to", "$subject", "$message", "$headers"))
{
echo "done";
}
else
{
echo "no";
}
응답을 받기까지 거의 10-12 초가 걸립니다. 나는이 코드에서 어떤 문제도 발견하지 못했습니다 ... 아주 간단한 스크립트와 아약스에 의해 보내지는 데이터가 입력 필드 값일뿐입니다.
감사
AJAX 호출없이 PHP 스크립트 자체를 실행 해보십시오. 당신은 여전히 매우 느린 반응을 얻나요? – Terry
@ 테리 예 시간 걸릴 – Gopal
그러면 고객 측 코드 문제의 가능성을 줄일 수 있습니다. '$ _POST' 객체의 크기는 얼마입니까? 당신은 그것을 반복하고 있습니다. – Terry