Switcher feature not functioning properly

Switcher feature not functioning properly

I  am trying to build a simple switcher feature.

What is happening right now is, if originally everyone is selected and if I click on only friends, 'selected' class is properly assigned to only friends and removed from everyone. But if originally only friends is selected, nothing happens.


  1.             $(".switcher span").click(function(){
  2.                 $.ajax({
  3.                     type: "GET",
  4.                     url: "content/profile/index.cs.asp?Process=ChangeComm",
  5.                     success: function(data) {
  6.                     if ($(this).is('.public')) {
  7.                         $(".public").addClass('selected');
  8.                         $(".limited").removeClass('selected');
  9.                     } else {
  10.                         $(".limited").addClass('selected');
  11.                         $(".public").removeClass('selected');
  12.                     }
  13.                     return false;
  14.                     },
  15.                     error: function (data) {                       
  16.                     }
  17.                 });
  18.             });
  19.                                     <div class="switcher">
  20.                                         <span class="desc">güncellemeler</span>
  21.                                         <span class="public <% If strDisplayComm = 1 Then %>selected<% End If %>">everyone</span>
  22.                                         <span class="limited <% If strDisplayComm = 0 Then %>selected<% End If %>">only friends</span>
  23.                                     </div>