[英]how window.location having again redirect in php file?
I am using the JS window.location
as:我使用 JS window.location
作为:
window.location.href = "my_url.php?param=1"
my_url.php
having again redirect using header()
function. my_url.php
再次使用header()
函数重定向。
If param=1
I am having code for download CSV , otherwise redirect to other URL.如果param=1
我有下载 CSV 的代码,否则重定向到其他 URL。
UPDATE:更新:
Redirect using JS:使用 JS 重定向:
// Download CSV
$( '#download_csv' ).on( 'click', function() {
window.location.href ="my_url.php?param=1"; // param is dynamic will be sent or not
});
my_url.php my_url.php
if($param == 1)
{
//CODE for download CSV, It works fine as intended
}
else
{
header("Location:other_page.php");//no actual redirect happens, instead I got ajax output of other_page.php
exit;
}
Problem: whatever the output of other_page.php it will get printed but my Addressbar is having the URL of my_url.php问题:无论 other_page.php 的输出如何,它都会被打印,但我的地址栏有 my_url.php 的 URL
If you want to check param
in my_url.php and according to it if you have to redirect then check param using $_GET then apply redirection如果你想在my_url.php 中检查param
并根据它是否必须重定向然后使用 $_GET 检查 param 然后应用重定向
my_url.php my_url.php
$param = (isset($GET['param']))?GET['param']:"";
if($param == 1)
{
//CODE for download CSV,
}
else
{
header("Location:other_page.php");//redirect to other page
exit;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.