Ivan Borshchov
Ivan Borshchov

Reputation: 3564

ObtaI n url of page which fired ajax request in ajax view

I have some page /page/< some_id >/. On this page I have form which are sent to some other url /ajaxreq/. Is it possible to read /page/< some_id >/ from request object in /ajaxreq/ view?

PS: I know, this is a design issue and there are many other ways to solve it, but it is interesting is such approach possible or not? It will be very useful and graceful in some cases.

Upvotes: 0

Views: 33

Answers (2)

Adrian Ghiuta
Adrian Ghiuta

Reputation: 1619

You could use request.META.get('HTTP_REFERER') in the view and extract the info from there.

Upvotes: 1

Aramil Rey
Aramil Rey

Reputation: 3475

You can do that with JS It should be something like this:

var link = [];
var url = window.location.pathname;
link = url.split('/');

var some_id = link[link.length-1];

Upvotes: 0

Related Questions