amit提出了一个问题:non-AJAX jquery POST request,或许与您遇到的问题类似。
回答者Doug Neiner给出了该问题的处理方式:
I know what you are trying to do, but its not what you want.
First, unless you are changing data on the server, don't use a POST request. Just have #see_comments be a normal ...
If you have to use POST, then do this to get the page to follow your call:
$("#see_comments").click(function() {
$('
' +'' +
'
').submit();});
How this would actually work.
First $.post is only an AJAX method and cannot be used to do a traditional form submit like you are describing. So, to be able to post a value and navigate to the new page, we need to simulate a form post.
So the flow is as follows:
You click on the image, and your JS code gets the imgnum
Next, someone clicks on #see_comments
We create a temporary form with the imgnum value in it as a hidden field
We submit that form, which posts the value and loads the comments.php page
Your comments.php page will have access to the posted variable (i.e. in PHP it would be $_POST['aid'])
希望本文对你有帮助,欢迎支持JavaScript中文网