Click to See Complete Forum and Search --> : Retrieve a webpage


ryan0204
May 28th, 2005, 02:19 PM
Is it possible to use javascript to store the output of a php page into a variable?
I know how to do something like that by using javascript and redirecting to another page, but I want to know if there's a way to do this within a js function without making the user leave the current page.

PeejAvery
June 8th, 2005, 12:03 PM
Like this?

<script language="JavaScript">
window.alert("<?php echo $_POST['postvariablename']; ?>");
</script>

Dr. Script
June 8th, 2005, 02:11 PM
Just recall that the page has to be of PHP extension for the code to work. Otherwise, you'll get the string literal of the php code.