J'utilise le window.location
JS comme:comment window.location ayant de nouveau rediriger dans le fichier php?
window.location.href = "my_url.php?param=1"
my_url.php
ayant rediriger à nouveau en utilisant la fonction header()
.
Si j'ai param=1
J'ai le code pour télécharger CSV, ou rediriger vers d'autres URL.
MISE À JOUR:
Redirect utilisant 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
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;
}
Problème: quelle que soit la sortie de other_page.php il s'imprimé mais ma barre d'adresse a l'URL de my_u rl.php
Quel est le problème? Si vous redirigez, vous redirigez – mplungjan
s'il vous plaît montrer ce que vous avez fait –
_Kindly fournir une solution à quoi? Il redirigera, si vous l'avez codé. –