Shivang
Shivang

Reputation: 196

get the url from which the ajax call has been made in the ajax function

For example, I have an ajax request from the page http://www.abc.com/xyz/1 to the function controlling ajax.

Is there any way except sending it through the parameters so that I could know that in the function I can fetch http://www.abc.com/xyz/1 and realise that the ajax request came from here?

Upvotes: 8

Views: 10048

Answers (2)

Bhaskar Bhatt
Bhaskar Bhatt

Reputation: 1467

you can get request url by using below php code:

 $request_url=( $_SERVER["HTTP_REFERER"]);

Upvotes: 3

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167172

If the server wants to know from which page, or the server's location, then you can use this in the end, if PHP:

die($_SERVER["HTTP_HOST"] . $_SERVER["HTTP_REFERER"]);

Upvotes: 9

Related Questions