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
Post a Comment