jQuery ajax引用网址


                    

如何在ajax请求中获取引荐来源网址?</ p>

名为main.php的文件具有jQuery,该jQuery将ajax调用发送到名为request.php的文件。</ p>

当我在request.php上时,是否有可能找出引荐来源网址? 确切地说,我想在运行request.php时动态地打印字符串“ main.php”。</ p>
     </ div>

展开原文

原文

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.

2个回答


通常,浏览器将使用标头 Referer </ code>作为ajax请求的一部分发送引荐页面,以便您阅读</ p>

所以您可以做类似的事情</ p>

  $ _ SERVER ['HTTP_REFERER']
</ code> </ pre>


  • 如何获取PHP中的“ referer”标头 ? </ li>
    </ ul>


    如果您不想依赖默认的 Referer </ code>标头,请传递您自己的自定义标头</ p>

      $(document).ajaxSend(function(event,jqXHR){
         jqXHR.setRequestHeader('my-referer','some-value');
    });
    </ code> </ pre>
         </ div>

展开原文

原文

Normally 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']

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');
});


是对request.php的支持,您可以像这样$ _SERVER ['HTTP_REFERER'] </ p>获得裁判。
     </ div>

展开原文

原文

yes on request.php u can get referee like this $_SERVER['HTTP_REFERER']

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐