J-bob
J-bob

Reputation: 9096

Getting the page URL where an AJAX call originated from

Many (probably the majority) of AJAX calls are done by a browser on a webpage and that webpage has a URL. Is it possible for a webserver to that's receiving the AJAX request to determine the URL of the webpage where the AJAX call was made? I assume there isn't a standard that requires this data in the headers, but perhaps some browsers include that info? Obviously this doesn't apply if the AJAX call was made from a phone app or other application without a URL.

Upvotes: 1

Views: 77

Answers (1)

Brad Christie
Brad Christie

Reputation: 101604

Very generically (though unreliable), check incoming request headers for Referer. That should give you information about the source page.

Just keep in mind it can be spoofed, absent, etc. and shouldn't be considered bullet-proof (though it doesn't sound like you need it to be anyways).

Upvotes: 2

Related Questions