| | 4 | $("#switchFollow").click(function(){ |
| | 5 | if($(this).attr('href').match('create')){ |
| | 6 | $.post( |
| | 7 | $(this).attr('href'), |
| | 8 | null, |
| | 9 | function(response, status){ |
| | 10 | if(response['error'] == 0){ |
| | 11 | $("#switchFollow").attr('href', $("#switchFollow").attr('href').replace('create', 'destroy')); |
| | 12 | $("#switchFollow img").attr('src', $("#switchFollow img").attr('src').replace('unfollowing.png', 'following.png')); |
| | 13 | } |
| | 14 | notice(response['message']); |
| | 15 | return false; |
| | 16 | }, |
| | 17 | 'json' |
| | 18 | ); |
| | 19 | } else { |
| | 20 | $.post( |
| | 21 | $(this).attr('href'), |
| | 22 | null, |
| | 23 | function(response, status){ |
| | 24 | if(response['error'] == 0){ |
| | 25 | $("#switchFollow").attr('href', $("#switchFollow").attr('href').replace('destroy', 'create')); |
| | 26 | $("#switchFollow img").attr('src', $("#switchFollow img").attr('src').replace('following.png', 'unfollowing.png')); |
| | 27 | } |
| | 28 | notice(response['message']); |
| | 29 | return false; |
| | 30 | }, |
| | 31 | 'json' |
| | 32 | ); |
| | 33 | } |
| | 34 | return false; |
| | 35 | }); |
| | 36 | |