I'm having a lot of trouble sending data from one page to another. I'm developing a movie website that displays movies on the homepage and when I click on a movie I want to access the movie details page with reviews. In fact, I want to send the movie ID to the movie-detail.php page because I want to filter the comments related to that movie in the comments section of the movie detail page. This is the movie poster in the homepage, created by using append in a js file, when I click on it:
... ...It triggers this function:
function loadComments(movieId){ $.post("/web/action/show-comments.php", { movieId }); }This is show-comments.php:
Commenter:
show-comments.php
is included in the comments section div of themovie-detail.php
page, but when I try to enter the page, it Always gives me undefined array key error regarding $movieId variable. The only thing I need is the movie ID. I've tried many things, using cookies and hiding input fields, but none seem to work, always giving me this error. I tried printing the$_POST
array but it was empty. What did i do wrong?
Try the following methods and correct them if there are any errors. I think you are not using the $.post() function correctly because the movieId is not properly formatted as a key value pair. Please try the following methods