Passing xml from php to javascript?
Hey guys, I'm new to php. Right now I'm trying to pass a xml string from php to javascript. I've tried with simple strings, and it works. Code like this:
<?php
$color = "green";
?>
<script language="JavaScript">
document.write("<?php echo($color);?>");
</script>
would output:
green.
But when I have something like this:
<?php
include 'xml.php';
?>
<script language="JavaScript">
document.write("<?php echo($xml);?>");
</script>
with 'xml.php' defining a variable $xml that includes an xml string, it no longer works, it gives some thing like:
- <script language="JavaScript">
document.write("
- <markers>
...
xml info
...
</markers>
");
</script>
Can someone please let me know how to get xml string from php to javascript? Thanks a lot!
Jim
Last edited by csxcsx; July 7th, 2010 at 02:44 PM..
|