admin管理员组文章数量:1023263
How can I get the url of the referer in an ajax request?
A file named main.php has jQuery that sends an ajax call to a file named request.php.
Is it possible to somehow figure out the referer when I'm on request.php? To be precise, I want to print the string "main.php" (dynamically) while running request.php.
How can I get the url of the referer in an ajax request?
A file named main.php has jQuery that sends an ajax call to a file named request.php.
Is it possible to somehow figure out the referer when I'm on request.php? To be precise, I want to print the string "main.php" (dynamically) while running request.php.
Share Improve this question asked Nov 5, 2014 at 9:56 sleepless_in_seattlesleepless_in_seattle 2,2344 gold badges27 silver badges37 bronze badges2 Answers
Reset to default 3Normally the the browser will send the referer page using the header Referer
as part of the ajax request so you can read it
So you could do something like
$_SERVER['HTTP_REFERER']
- How do you get the 'referer' header in PHP?
If you don't want to depend on the default Referer
header, pass a custom header of your own
$(document).ajaxSend(function (event, jqXHR) {
jqXHR.setRequestHeader('my-referer', 'some-value');
});
yes on request.php u can get referee like this $_SERVER['HTTP_REFERER']
How can I get the url of the referer in an ajax request?
A file named main.php has jQuery that sends an ajax call to a file named request.php.
Is it possible to somehow figure out the referer when I'm on request.php? To be precise, I want to print the string "main.php" (dynamically) while running request.php.
How can I get the url of the referer in an ajax request?
A file named main.php has jQuery that sends an ajax call to a file named request.php.
Is it possible to somehow figure out the referer when I'm on request.php? To be precise, I want to print the string "main.php" (dynamically) while running request.php.
Share Improve this question asked Nov 5, 2014 at 9:56 sleepless_in_seattlesleepless_in_seattle 2,2344 gold badges27 silver badges37 bronze badges2 Answers
Reset to default 3Normally the the browser will send the referer page using the header Referer
as part of the ajax request so you can read it
So you could do something like
$_SERVER['HTTP_REFERER']
- How do you get the 'referer' header in PHP?
If you don't want to depend on the default Referer
header, pass a custom header of your own
$(document).ajaxSend(function (event, jqXHR) {
jqXHR.setRequestHeader('my-referer', 'some-value');
});
yes on request.php u can get referee like this $_SERVER['HTTP_REFERER']
本文标签: javascriptjQuery ajax referer urlStack Overflow
版权声明:本文标题:javascript - jQuery ajax referer url - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745599152a2158351.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论