类似facebook无刷新ajax更新

2014-11-24 01:03:54 · 作者: · 浏览: 0

类似facebook无刷新ajax更新

类似facebook无刷新ajax更新演示

XML/HTML Code
  1. <script type="text/java script">
  2. $(document).ready(function()
  3. {
  4. $('.edit_link').click(function()
  5. {
  6. $('.text_wrapper').hide();
  7. var data=$('.text_wrapper').html();
  8. $('.edit').show();
  9. $('.editbox').html(data);
  10. $('.editbox').focus();
  11. });
  12. $(".editbox").mouseup(function()
  13. {
  14. return false
  15. });
  16. $(".editbox").change(function()
  17. {
  18. $('.edit').hide();
  19. var boxval = $(".editbox").val();
  20. var dataString = 'data='+ boxval;
  21. $.ajax({
  22. type: "POST",
  23. url: "update_profile_ajax.php",
  24. data: dataString,
  25. cache: false,
  26. success: function(html)
  27. {
  28. $('.text_wrapper').html(boxval);
  29. $('.text_wrapper').show();
  30. }
  31. });
  32. });
  33. $(document).mouseup(function()
  34. {
  35. $('.edit').hide();
  36. $('.text_wrapper').show();
  37. });
  38. });
  39. Edit
  40. include("db.php");
  41. $sql=mysql_query("select email from users where user_id='1'");
  42. $row=mysql_fetch_array($sql);
  43. $profile=$row['email'];
  44. >