码迷,mamicode.com
首页 > 其他好文 > 详细

【技术】Ajax $.get()

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

标签: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()

标签:io   java   ar   for   2014   div   sp   cti   on   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!