實(shí)現(xiàn)類似facebook無(wú)刷新ajax更新
更新時(shí)間:2014年03月17日 15:04:53 作者:
這篇文章主要介紹了實(shí)現(xiàn)類似facebook無(wú)刷新ajax更新,需要的朋友可以參考下

復(fù)制代碼 代碼如下:
<script type="text/javascript">
$(document).ready(function()
{
$('.edit_link').click(function()
{
$('.text_wrapper').hide();
var data=$('.text_wrapper').html();
$('.edit').show();
$('.editbox').html(data);
$('.editbox').focus();
});
$(".editbox").mouseup(function()
{
return false
});
$(".editbox").change(function()
{
$('.edit').hide();
var boxval = $(".editbox").val();
var dataString = 'data='+ boxval;
$.ajax({
type: "POST",
url: "update_profile_ajax.php",
data: dataString,
cache: false,
success: function(html)
{
$('.text_wrapper').html(boxval);
$('.text_wrapper').show();
}
});
});
$(document).mouseup(function()
{
$('.edit').hide();
$('.text_wrapper').show();
});
});
</script>
<style type="text/css">
body
{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
.mainbox
{
width:250px;
margin:50px;
}
.text_wrapper
{
border:solid 1px #0099CC;
padding:5px;
width:187px;
}
.edit_link
{
float:right
}
.editbox
{
overflow: hidden; height: 61px;border:solid 1px #0099CC; width:190px; font-size:12px;font-family:Arial, Helvetica, sans-serif; padding:5px
}
</style>
<div class="mainbox">
<a href="#" class="edit_link" title="Edit">Edit</a>
<?php
include("db.php");
$sql=mysql_query("select email from users where user_id='1'");
$row=mysql_fetch_array($sql);
$profile=$row['email'];
?>
<div class="text_wrapper" style=""><?php echo $profile; ?></div>
<div class="edit" style="display:none"><textarea class="editbox" cols="23" rows="3" name="profile_box"></textarea></div>
</div>
update_profile_ajax.php
復(fù)制代碼 代碼如下:
<?php
if($_POST['data'])
{
$data=$_POST['data'];
$data = mysql_escape_String($data);
$sql = "update users set email='$data' where user_id='1'";
mysql_query( $sql);
}
?>
相關(guān)文章
Ajax 高級(jí)功能之a(chǎn)jax向服務(wù)器發(fā)送數(shù)據(jù)
這篇文章主要介紹了Ajax 高級(jí)功能之a(chǎn)jax向服務(wù)器發(fā)送數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2016-08-08
本人ajax留言板的源程序 不錯(cuò)的應(yīng)用js
本人ajax留言板的源程序 不錯(cuò)的應(yīng)用js...2007-09-09
利用AjaxControlToolkit實(shí)現(xiàn)百度搜索時(shí)的下拉列表提示詳細(xì)步驟
AjaxControlToolkit是一組控件的集合,可以實(shí)現(xiàn)自動(dòng)補(bǔ)充文本框,點(diǎn)擊文本框彈出日歷,加水印等Ajax效果等等,感興趣的朋友可以了解下啊,或許本文對(duì)你學(xué)習(xí)ajax有所幫助2013-02-02
Ajax調(diào)用restful接口傳送Json格式數(shù)據(jù)的方法
這篇文章主要介紹了Ajax調(diào)用restful接口傳送Json格式數(shù)據(jù)的方法的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起看下吧2016-07-07
Ajax實(shí)現(xiàn)注冊(cè)并選擇頭像后上傳功能
這篇文章主要介紹了Ajax實(shí)現(xiàn)注冊(cè)并選擇頭像后上傳功能,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-02-02
通過(guò)Ajax請(qǐng)求動(dòng)態(tài)填充頁(yè)面數(shù)據(jù)的實(shí)例
今天小編就為大家分享一篇通過(guò)Ajax請(qǐng)求動(dòng)態(tài)填充頁(yè)面數(shù)據(jù)的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-08-08
用AJAX實(shí)現(xiàn)頁(yè)面登陸以及注冊(cè)用戶名驗(yàn)證的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)?lái)一篇用AJAX實(shí)現(xiàn)頁(yè)面登陸以及注冊(cè)用戶名驗(yàn)證的簡(jiǎn)單實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10

