------------------------ 개별 전달
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<form id="frm" method="post">
<input type="text" id='text01'>
<input type="text" id='text02'>
<input type="text" id='text03'>
</form>
<button type="button" id='action-button' >Default</button>
<div id="info"></div>
<script>
$('#action-button').click(function() {
$.ajax({
url: '전달받는URL',
data: {"text01": $('#text01').val(), "text02": $('#text02').val(), "text03": $('#text03').val()},
error: function() {
$('#info').html('<p>An error has occurred</p>');
},
dataType: 'html',
success: function(data) {
$("#info").empty();
$('#info').append(data);
},
type: 'POST'
});
});
</script>
----------------------------- 전체 전달
>>>> 전달 하는 페이지
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<form action="tt2.html" method="post" name="myForm" id="myForm">
<input type="text" name="user" id="user" value='' />
<input type="text" name="pass" id="pass" />
</form>
<input type="button" name="smt" id="smt" onclick='test()' value="Submit" />
<div id="msgx"></div>
<script>
$("#smt").click(function(){
var form=$("#myForm");
$.ajax({
type:"POST",
url:"tt2.html",
data:form.serialize(),
success: function(response){
$('#msgx').append(response);
}
});
});
</script>
>>>>>> 받는 페이지
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
if($user=="hongtting")
{
echo "HI ".$user;
}
else
{
echo "I dont know you.";
}
?>