당신은 정말하지 "필요"AJAX 이것에 대한 당신은 자신에 제출 프로세스 파일을 포함 할 수 있기 때문에 :
의 index.php
을
<div id="result">
<?php include('process.php'); ?>
</div>
<form action="index.php" id="form" method="get">
<input type="text" id="q" name="q" maxlength="16">
<input type="submit" name="submit" value="Submit">
</form>
process.php
<?php
// Check if form was submitted
if(isset($_GET['submit'])){
$result = $_GET['q'];
if($result == "Pancakes") {
echo 'Result is Pancakes';
}
else {
echo 'Result is something else';
}
}
?>
AJAX를 구현하면 일을보다 사용자 친화적으로 수행 할 수 있지만 코드가 복잡해집니다. 어떤 길로 행운을 빌어 요!
이
은 그것을 할
<script>
//wait for page load to initialize script
$(document).ready(function(){
//listen for form submission
$('form').on('submit', function(e){
//prevent form from submitting and leaving page
e.preventDefault();
// AJAX goodness!
$.ajax({
type: "GET", //type of submit
cache: false, //important or else you might get wrong data returned to you
url: "process.php", //destination
datatype: "html", //expected data format from process.php
data: $('form').serialize(), //target your form's data and serialize for a POST
success: function(data) { // data is the var which holds the output of your process.php
// locate the div with #result and fill it with returned data from process.php
$('#result').html(data);
}
});
});
});
</script>
AJAX에 대한 확신이 있다면 그것에 대해 조금 읽으십시오. 구글'AJAX' 이상 : – Alvaro
AJAX를 아직 사용해 보지 않으셨습니까? AJAX를 사용해보고 문제를 말해주십시오. –
[** Google에서 div 형식으로 결과 표시 php **] (https://www.google.ca/search?q=show+result+in+div+form+php&ie=utf-8&oe=utf-8&rls=org .mozilla : ko-ko : 공식 및 클라이언트 = firefox-a & 채널 = np 및 source = hp & gws_rd = cr) –