Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在php文件中再次重定向window.location?_Javascript_Php_Url Redirection - Fatal编程技术网

Javascript 如何在php文件中再次重定向window.location?

Javascript 如何在php文件中再次重定向window.location?,javascript,php,url-redirection,Javascript,Php,Url Redirection,我将JS window.location用作: my_url.php再次使用头函数重定向 如果param=1,我有用于下载CSV的代码,否则重定向到其他URL 更新: 使用JS重定向: // Download CSV $( '#download_csv' ).on( 'click', function() { window.location.href ="my_url.php?param=1"; // param is dynamic will be sent or

我将JS window.location用作:

my_url.php再次使用头函数重定向

如果param=1,我有用于下载CSV的代码,否则重定向到其他URL

更新:

使用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

问题:无论other_page.php的输出是什么,它都会被打印出来,但是我的地址栏中有my_URL.php的URL

如果您想在my_URL.php中检查param,并且根据它如果您必须重定向,则使用$\u get检查param,然后应用重定向

my_url.php


有什么问题?如果你重定向,你重定向。请展示你所做的。你能提供一些解决方案吗?它将重定向,如果你已经编码了。你的问题不清楚我们可以帮助,但我们需要知道你需要什么帮助。那么问题又是什么?什么是预期的和实际的结果?这是不起作用的,因此问题张贴。它为我提供了other_page.php的ajax输出,而不是redirectwindow.location.href将您重定向到其他页面。如果您使用的是ajax,请使用完整的代码更新您的问题。在您的问题中,您没有指定关于ajax的任何内容。你的问题不清楚
    // Download CSV 
$( '#download_csv' ).on( 'click', function() {
        window.location.href ="my_url.php?param=1"; //  param is dynamic will be sent or not
    });
    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;
    }
$param = (isset($GET['param']))?GET['param']:"";
if($param == 1)
{
    //CODE for download CSV, 
}
else
{
    header("Location:other_page.php");//redirect to other page
    exit;
}