Всем привет!
Подгружаются данные :
<!doctype html>
<html lang="ru">
<head>
<style>
input, textarea{
display: block;
margin-bottom: 5px;
}
</style>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://code.jquery.com/jquery-1.11.0."></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
$(function(){
$(".sub").click(function(){
var name = document.getElementsByID("name");
var mail = document.getElementsByID("mail");
var mess = document.getElementsByID("mess");
$.ajax({
url: 'ajax.php',
type 'post',
data: {name: name, mail: mail, mess: mess},
success: function(data){
$("#data").html(data);
}
});
});
});
</script>
</head>
<body>
<form action="ajax.php" method="post" onsubmit="return false">
<input type="text" name="name" class="name" id="name" />
<input type="text" name="mail" class="mail" id="mail" />
<textarea name="mess" class="message" id="mess" cols="40" rows="7"></textarea>
<input type="submit" name="sub" class="sub"/>
</form>
<div id="data"></div>
</body>
</html>
и файл обработчик 'ajax.php':
<?php
$name = $_POST['name'];
$mail = $_POST['name'];
$mess = $_POST['mess'];
if($_POST){
echo $name."<br/>".$mail."<br/>".$mess;
}
?>