I'm doing a lightbox that appears (using javascript + AJAX + get) when I click a like.

The use case is:
1. Click a link
--> the lightbox with a form appears
2. Insert info
3. Click a button
--> An answer to your input appears

The problem:
I reuse the code of the box in different pages since the form is the same but the answer is different according to the page you're in.
How can I know where I came from when I'm on the server side computing the answer?

The only solution I found was sending parameter on 1 the having a hidden input on the pop up and finally in 3 sending the info again.
But I think this is awful. Is there another way?