Implementation like Facebook no refresh Ajax update

Source: Internet
Author: User

  This article mainly introduces the implementation of similar Facebook without refreshing Ajax updates that need friends to refer to under

  Code as follows: <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  {& nbsp float:right }  .editbox  {  overflow:hidden; height:61px;border:solid 1px #0099CC; width:190px; fo Nt-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=" rows= "3" name= "Profile_box" ></textarea></div>   </div>    update_profile_ajax.php    code as follows: <?php    if ($_post[' data ')   {  $data =$_post[' data '];  $data = mysql_escape_string ($data);  $sql = "Update users set email=" $dat A ' where user_id= ' 1 ' ";  mysql_query ($sql); } ?>   
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.