Вы действительно не "нужно" 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 сделает вещи более удобными, но это определенно усложняет ваш код. Так что удачи в любом маршруте!
Это JQuery 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 (это способ сделать это), прочитайте немного об этом. Google '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: ru-US: official & client = firefox-a & channel = np & source = hp & gws_rd = cr) –