日期:2014-05-16 浏览次数:20419 次
<script type="text/javascript" >
function post()
{
var text;
text = document.getElementById('textarea').value; //获取textarea的值
//document.getElementById("myDiv").innerHTML=text;
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("mainDiv").innerHTML=xmlhttp.responseText;
document.getElementById("myDiv").innerHTML="发布成功";
//setTimeout(function(){document.getElementById("myDiv").innerHTML="<br>";},2500);
/* $(document).ready(function(){
$("#button").bind("click",function(){
$("#myDiv").fadeOut("3000");
});
});
*/
}
}
xmlhttp.open("POST","post.jsp",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
text = encodeURI(text);
text = encodeURI(text);
xmlhttp.send("utext="+text);
}
</script>
<script>
$(document).ready(function(){
$("#button").bind("click",function(){
$("#myDiv").fadeOut("3000");
});
});
</script>
<input id="button" value="发布 " type="button" onclick="post();">
<script type="text/javascript" >
$(document).ready(function(){
$("#button").bind("click",function(){
var text = $('#textarea').val();
$("#myDiv").text("数据提交中..").show();
$.ajax({
type: "POST",
url: "post.jsp",
data: { utext: text },
success: function(msg){
$("#mainDiv").html(msg);
$("#myDiv").text("发布成功").fadeOut("3000");