Search the Community
Showing results for tags 'situation'.
-
Say my goal is to have posts with user comments with each individual post. And these posts are posted in relavent catagories. This is all done. Works beautifully. Now say my 2nd goal is to use ajax for everytime a user posts a comment in a post, it'll load the comment without refreshing the page. This is where I am having an issue. So say this is my setup. index.php <a href="records.php?title=<?php echo $record_id; ?>"> records.php <head> script type="text/javascript"> $(document).ready(function(){ $(".comment_button").click(function() { var element = $(this); var test = $("#content").val(); var dataString = 'content='+ test; if(test=='') { alert("Please Enter Some Text"); } else { $.ajax({ type: "POST", url: "ajax.php", data: dataString, cache: false, success: function(data){ $('#display').html(data); document.getElementById('content').value=''; } }); } return false; }); }); </script> </head> <body> <form method="post" name="form" action=""> <textarea name="content" id="content" cols="45" rows="5"></textarea> <input type="submit" value="Update" id="v" name="submit" class="comment_button"/> </form> <div id="display" align="left"> <div> </body> ajax.php // need to get id of current post here. Of course this is not the complete code but you get the idea. The queries that insert and the get the records work. The only issue I have is that the 'get' query won't get the current post id. It makes sense since it's in ajax.php and it's processing through the ajax function. If that query was on records.php, yes it will work. So my question is, is there a way around it?