I have a concatenated list of posts like this:
And here is the javascript/ajax, which sends the variables to the _removepost.php, in order to run that code, and delete the post from the database...Code:<?php // this generates a list of divs with unique id's as $post_id's $my_posts .= ' <div class="storypost' . $post_id . '"> <a href="mystorypost.php?id=' . $post_id . '>' . $member_name . ' Post</a> <a href="#" onclick="DoAction(' . $mem_id . ', ' . $post_id . ');">Remove?</a> </div> '; ?>
So, the thing actually works (the post gets deleted from the database). But what does not work, is:Code:<script> function DoAction(mem_id, post_id) { var r = confirm('Are you sure you want to remove this post?'); if (r == true) { $.ajax({ type: "GET", url: "_removepost.php", data: "mem_id=" + mem_id + "&post_id=" + post_id, }); $(".storypost"+post_id).hide(); return false; } else { return; } } </script>
1) the div is not getting hidden via the .hide()
2) after I click the onClick link, the page scrolls back to the top of the page... and I have to end up reloading the page to see the change.
I believe there is something wrong with where I placed the "return false;" and something wrong with how I call the variable in .hide().


Reply With Quote

Bookmarks