I know what you are trying to do, but that is not what you want.
First, if you do not modify the data on the server, do not use the POST request. Just #see_comments will be normal <a href='/comments.php?aid=1'>...
If you need to use POST , then do this so that the page matches your call:
$("#see_comments").click(function() { $('<form action="comments.php" method="POST">' + '<input type="hidden" name="aid" value="' + imgnum + '">' + '</form>').submit(); });
How it really works.
The first $.post is just an AJAX method and cannot be used to execute the traditional form submit as you describe. Thus, in order to be able to publish the value and go to a new page, we need to simulate a form post.
So the stream is as follows:
- You click on the image and your JS code gets
imgnum - Then someone clicks
#see_comments - We create a temporary
form with an imgnum value in it as a hidden field - We submit this form, which submits the value and loads the
comments.php page - Your
comments.php page will have access to the published variable (i.e. in PHP it will be $_POST['aid'] )
Doug Neiner Jan 13 '10 at 5:54 2010-01-13 05:54
source share