如何调用ajax显示输入内容?
如何才能简单的将输入的内容显示在区域内呢?我的这个简单的code中是不是有很大的问题?如何改正呢
2015-10-03
<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<style type="text/css">
#show{width:160px;
height:100px;
border:1px solid blue;
margin-bottom:10px;}
</style>
</head>
<body>
<div id="show"></div>
<div id="content">
<textarea></textarea>
</div>
<input id="click" type="button" value="点击" onclick="" />
<span></span>
<script>
$(function(){
$("#click").bind("click",function(){
var content = $("textarea").val();
$.ajax({
url:"",
type: "GET",
data:{
content: content,
},
success:function(data){
$("#show").html(content);
},
error:function(){
alert("发送失败");
}
});
})
})
$(document).ajaxStart(function(){
$("span").show().html("留言发送中..");
});
$(document).ajaxStop(function(){
$("span").show().html("留言成功!");
});
</script>
</body>
</html代码已贴上,你自己对照
举报