Jump to content

jquery .load on setInterval, buttons inside dont work until i refresh page?


shortysbest

Recommended Posts

i have a notifications system on my website for friend requests, when someone sends a friend request the user gets a auto-notification, well i have another.load for when the user clicks on the notifications button, a drop down menu displays with the users friend requests, I have "accept" "decline" that i also use jquery to add/decline friend request, however when you get the notification (without reloading page) when you click on accept/decline it doesn't work, then when u reload the page they work, however after i click one of them, if there are multiple requests, the buttons on the other requests don't work until page refresh, But add friend and decline friend both work at same time on the current request.

 

Here's some of my code:

 

reloads the div each 10 seconds. (also have a problem when the time isn't 10 or more seconds, the buttons don't work.

 

setInterval(function (){$j('#notificationbox').load('php/notifications/get_frequests.php');}, 10000);

 

this would be my query to send the decline friend request:

 

$j(function() {
$j(".notifications-frequest-decline").click(function(){
var element = $j(this);
var noteid = element.attr("id");
var info = 'friend_id=' + noteid;

$j.ajax({
   type: "POST",
   url: "php/profile/decline_friend.php",
   data: info,
   cache: false,
   success: function(html){}
});
    $j(this).html('Friend declined');

return false;

});
});

 

if anyone could help that would be great :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.