標籤:io java ar for 2014 div sp cti on
HTML:
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function(){
$(document).on("click","#send",function(){
$.get("get1.php",{
username:$("#username").val(),
content:$("#content").val()
},function(result){
$("#content").val(result);
});
});
});
// $(function(){
// $("send").click(function(){
// $.get("get1.php",{
// username:$("#username").val(),
// content:$("#content").val()
// },function(data,textStatus){
// $("#resText").html(data);
// });
// });
// });
</script>
</head>
<body>
<form id="form1" action="#">
<p>
評論:
</p>
<p>
姓名:
<input type="text" name="username" id="username" />
</p>
<p>
內容:
<textarea name="content" id="content" rows="2" cols="20">
</textarea>
</p>
<p>
<input type="button" id="send" value="提交" />
</p>
</form>
<div class="comment">
已有評論:
</div>
<div id="resText"></div>
</body>
</html>
get1.php:
<?php
//echo "123";
$username = $_GET[‘username‘];
if($username == "冰冰"){
echo "好人";
}else{
echo "壞人";
}
//$arr = array(‘title‘=>"2014熱門排行榜",‘data‘=>array(‘id‘=>1,‘name‘=>‘要冰冰‘));
// echo json_encode($arr);
?>
【技術】Ajax $.get()