Forum Moderators: open

Message Too Old, No Replies

return php variables to javascript function

php mysql ajax

         

phparion

4:50 am on Aug 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi

i want to use ajax in an application where one a button is clicked it calls a javscript function that function send a variables in URL to a php page and in php page i read data from mysql and store it in differnt variables now i want to get back these variables from php page, how can i do it?

thanks

rocknbil

8:07 pm on Aug 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One of two ways: either put the Javascript function right in your php output so that as it outputs the javacript it contains the values, OR split up the query string with your javascript to get at the values. Of the two, I'd say the first is probably more graceful. A perl-y example:


#!/usr/bin/perl
$myvalue = 'From the script';
$content = qq¦
<html><head>
<script type="text/javascript">
alert('$myvalue');
</script>
</head><body>test</body></html>
¦;
print "content-type: text/html\n\n";
print $content;