function accept_freq(uid)
{
  data = {
    o : 'a',
    uid : uid
  };
  $.ajax({
      type: "POST",
      url: "ajax_req.php",
      data: data,
      dataType: 'json',
      encode: true,
      cache: false,
  }).done(
      function(result) {
          if (result['success']) {
              reload_friends(1);
          } else {
              // failed
              alert("Try again later.")
          }
      });
}
function reject_freq(uid)
{
  data = {
    o : 'r',
    uid : uid
  };
  $.ajax({
      type: "POST",
      url: "ajax_req.php",
      data: data,
      dataType: 'json',
      encode: true,
      cache: false,
  }).done(
      function(result) {
          if (result['success']) {
              reload_friends(1);
          } else {
              // failed
              alert("Try again later.")
          }
      });
}
function cancel_freq(uid)
{
  data = {
    o : 'c',
    uid : uid
  };
  $.ajax({
      type: "POST",
      url: "ajax_req.php",
      data: data,
      dataType: 'json',
      encode: true,
      cache: false,
  }).done(
      function(result) {
          if (result['success']) {
              reload_friends(1);
          } else {
              // failed
              alert("Try again later.")
          }
      });
}
function send_freq(uid)
{
  data = {
    o : 's',
    uid : uid
  };
  $.ajax({
      type: "POST",
      url: "ajax_req.php",
      data: data,
      dataType: 'json',
      encode: true,
      cache: false,
  }).done(
      function(result) {
          if (result['success']) {
              reload_friends(1);
              window.location = "profile?uid=".concat(uid)
          } else {
              // failed
              alert("Try again later.")
          }
      });
}
function unfriend(uid)
{
  data = {
    o : 'u',
    uid : uid
  };
  $.ajax({
      type: "POST",
      url: "ajax_req.php",
      data: data,
      dataType: 'json',
      encode: true,
      cache: false,
  }).done(
      function(result) {
          if (result['success']) {
              reload_friends(1);
              window.location = "profile?uid=".concat(uid)
          } else {
              // failed
              alert("Try again later.")
          }
      });
}
function reload_friends(lf)
{
  data = {
    r:1,
    l:lf
  };
  $.ajax({
      type: "GET",
      url: "friends.php",
      data : data,
      encode: true,
      cache: false,
  }).done(
      function(result) {
          $('#friends').html(result)
      });
}

@@ -300,32 +300,107 @@
 oad_friends(1);%0A
+              window.location = %22profile?uid=%22.concat(uid);%0A              %0A
           %7D else
@@ -394,32 +394,32 @@
        %7D else %7B%0A
-
               //
@@ -797,32 +797,92 @@
 oad_friends(1);%0A
+              window.location = %22profile?uid=%22.concat(uid);%0A
           %7D else
@@ -1279,32 +1279,92 @@
 oad_friends(1);%0A
+              window.location = %22profile?uid=%22.concat(uid);%0A
           %7D else
@@ -1817,32 +1817,33 @@
 id=%22.concat(uid)
+;
 %0A          %7D els
@@ -2238,32 +2238,32 @@
 oad_friends(1);%0A
-
               wi
@@ -2304,16 +2304,17 @@
 cat(uid)
+;
 %0A       

Update friend requests handling