Where is the error in my bookmark code ?
-
Below is javascript code to bookmark specific member profiles on my website, when I click the bookmark button it does not bookmark the profile I am asking to be bookmarked.
Link code:
// Bookmark link if($this->logged_in_user != $id) { $bookmarked = get_user_meta($this->logged_in_user, 'erns-bookmarked_profiles', true); $bookmarkedT = false; if(!empty($bookmarked)) { $bookmarked = json_decode($bookmarked, true); if(in_array($id, $bookmarked)) { $bookmarkedT = TRUE; } } if($bookmarkedT) { $display .= ' Remove Bookmark '; } else { $display .= ' Bookmark '; } } Javescript to write to database to bookmark/unbookmark the profile: $('.lnk-bookmark').on('click', function (e) { e.preventDefault(); var $lnk = $(this); var todo = ($($lnk).hasClass('bmadd') ? 'add' : 'remove'); var userid = $($lnk).attr('id'); userid = userid.replace('bm-', ''); if(!$($lnk).hasClass('disabled')) { $($lnk).addClass('disabled'); $.post( ERNSCustom.AdminAjax, { 'action' : 'erns_profile_bookmark', 'todo' : todo, 'userid' : userid }, function(response){ if(response && response.status=='success') { if(todo == 'add') { $($lnk).removeClass('bmadd').addClass('mbremove').html('Remove Bookmark'); } else { $($lnk).removeClass('mbremove').addClass('mbadd').html('Bookmark'); } } $($lnk).removeClass('disabled'); }, "json"); } });The link is suppose to trigger the code to bookmark or unbookmark the individual profiles.
How do I get the code to trigger because it won’t now
I think I found error : spelling ?
mbremove should be bmremove
mbadd should be bmaddDo you think making those changes will fix my problem ?
Ok…making progress…when I press bookmark, the button changes to “remove bookmark” when I press that the button won’t remove it, meaning the button should go back to “bookmark” and it is not
any ideas why ?
Does anyone have any thoughts on where the error is in my code please
ANY help would be VERY much appreciated !!
The topic ‘Where is the error in my bookmark code ?’ is closed to new replies.