首页 > 其他 > 详细

【技术】Ajax $.get()

时间:2014-09-12 13:12:33      阅读:256      评论:0      收藏:0      [点我收藏+]

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()

原文:http://www.cnblogs.com/ybingbing_1213/p/3968078.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!