mine.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. function Follow(obj,data){
  2. if(obj.hasClass('active'))
  3. {$.ajax ({
  4. type : "DELETE",
  5. url : "/user/follow",
  6. data:data,
  7. contentType: 'application/json;charset=UTF-8',
  8. success: function(result) {
  9. if (result.judge === true)
  10. {
  11. obj.text('关注').removeClass('active');
  12. }
  13. else
  14. {alert('asd');}}});
  15. }else
  16. {$.ajax ({
  17. type : "POST",
  18. url : "/user/follow",
  19. data:data,
  20. contentType: 'application/json;charset=UTF-8',
  21. success: function(result) {
  22. if (result.judge === true)
  23. {
  24. obj.text('取消关注').addClass('active');
  25. } else
  26. {alert('asd');}
  27. }});
  28. }
  29. }
  30. $(document).ready(function(){
  31. $('button.tagfollow').click(function(){
  32. var _$this = $(this);
  33. var data = JSON.stringify({
  34. id:_$this.attr("id"),
  35. type:'tag'
  36. });
  37. Follow(_$this,data);
  38. });
  39. $('button.topicfollow').click(function(){
  40. var _$this = $(this);
  41. var data = JSON.stringify({
  42. id:_$this.attr("id"),
  43. type:'topic'
  44. });
  45. Follow(_$this,data);
  46. });
  47. $('button.collectfollow').click(function(){
  48. var _$this = $(this);
  49. var data = JSON.stringify({
  50. id:_$this.attr("id"),
  51. type:'collect'
  52. });
  53. Follow(_$this,data);
  54. });
  55. });