I am trying to pass the ID of the clicked image to next page. When I developed my code, it didn\'t redirect me to the next page. When I click F12 and check the POST in network,
The entire point of Ajax is that that request is made with JavaScript and the response is handled by JavaScript without navigating to a new page.
If you want to make a POST request and navigate to the resulting page, then use a
window.location.href = 'userevent.php';
it redirect me but without the variable
Assigning a URL to location.href
triggers browser navigation (with a GET request) to that URL.
It is a completely different request to the Ajax request so it doesn't have the data from that request.
Again: Use a form for this.
I read the data from database and I get the clicked id of the images.
Put the data you want to send in a submit button instead.