ajax,没显示数据
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言栏</title>
<style type="text/css">
body{
background: #EDEFF0;
}
.contant{
background: #fff;
width: 500px;
height: 391px;
margin: 0 auto;
}
#liuyan{
width: 480px;
height: 200px;
border: 1px solid #eceff0;
margin: 0 auto;
overflow-y:scroll;
}
.tijiao{
width: 158px;
height: 42px;
background-color: #33A646;
color: #fff;
border: none;
}
h1{
font-size: 16px;
line-height: 49px;
color: #363d40;
width: 480px;
margin: 0 auto;
margin-bottom: 1em;
border-bottom: 1px solid #eceff0;
}
form{
padding: 10px;
font-size: 12px;
}
#textarea{
border: 1px solid #eceff0;
margin: 0;
}
.formr{
float: right;
line-height: 30px;
margin: 0;
padding: 0;
}
.name{
width: 100px;
}
</style>
<script src="http://www.imooc.com/data/jquery-1.8.2.min.js" type="text/javascript"></script>
</head>
<body>
<div class="contant">
<div class="fr">
<h1>留言栏</h1>
<div id="liuyan"></div>
<form>
<textarea id="textarea" rows=6 cols=40>骚年,哪有不爽,来喷吧!</textarea>
<span class="formr">用户名:
<input type="text" id="name" class="name" value="请输入昵称" /><br />
<input type="submit" id="sub" class="tijiao" value="提交" /><br />
<span id="msg"></span>
</span>
</form>
</div>
</div>
<script type="text/javascript">
$(function(){
$("#msg").ajaxStart(function(){
$(this).html("正在发送。。。");
}).ajaxStop(function(){
$(this).html("发送成功!");
});
var $textarea = $("#textarea");
var $name = $("#name");
$textarea.bind("click",function(){
if($(this).val()=="骚年,哪有不爽,来喷吧!")
$(this).val("");
})
$name.bind("click",function(){
if ($(this).val()=="请输入昵称")
$(this).val("");
})
$("#sub").bind("click",function(){
var $xiaoxi = getTime()+"<br />"+$name.val()+"说:"+"<br />"+$textarea.val()+"<br />";
var $jilu = $("#liuyan").html()+$xiaoxi;
if ($name.val()!="" && $textarea.val()!="") {
$.ajax({
url:"",
type:"GET",
data:$jilu,
success:function(data){
$("#liuyan").html($jilu);
$textarea.val("");
$name.val("");
}
})
}else{
if ($name.val()==""){
alert("昵称不能为空,请重新输入");
$name.focus();
return false;
}
else{
alert("发送内容不能为空,请重新输入");
$textarea.focus();
return false;
}
}
setTimeout(function(){
$("#msg").html("");
},1000);
})
})
var_dump($_POST);
function getTime(){
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth()+1;
var day = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var time = year+'/'+month+'/'+
day+' '+hours+':'+minutes+':'+seconds;
return time;
}
</script>
</body>
</html>