javascript - use parameters in window.location.replace -


i have following script works fine:

if(error1 == 1){     window.alert('you have signed up!');     window.location.replace('index.php');     } 

but when want use following url instead of index.php, not substitute parameters:

if(error1 == 1){     window.alert('you have signed up!');     window.location.replace('http://polimovie.deib.polimi.it/version3/index.php?campaign=".$campaign_id."&worker=".$worker_id."');     } 

this code, redirects me http://polimovie.deib.polimi.it/version3/index.php?campaign=.$campaign_id.&worker=.$worker_id. while need parameters replaced actual numbers.

i know can use php header, used within php codes , both workerd fine:

echo "<script>alert('please sign first!');window.location = 'http://polimovie.deib.polimi.it/version3/index.php?campaign=".$campaign_id."&worker=".$worker_id."';</script>"; 

but know how can use parameters window.location.replace.

thanks,

try below :

if(error1 == 1){     window.alert('you have signed up!');     window.location.replace('http://polimovie.deib.polimi.it/version3/index.php?campaign=<?php echo $campaign_id; ?>&worker=<?php echo $worker_id; ?>');     } 

above work if php file , not js file


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -