Support Spidean |
Do you like our FREE downloads? How about the FREE support for the FREE downloads? Please help us out and donate any amount! It's fast and easy through PayPal.
|
Shawn
|
posted on 2/3/2010 at 04:29 PM |
In general you would do it like this:
Your php page:
$id = $_GET['id'];
//do some database query and fetch the array
//json_encode the array and echo
echo json_encode(array('id'=>$id, 'name'=>'test', 'descr'=>'test
array from db'));
Your HTML page:
<html>
<head>
<script type="text/javascript">
xhttp = new XMLHttpRequest();
xhttp.open("GET", "http://example.com/script.php?id=1", false);
xhttp.send("");
response = xhttp.responseText;
var myArray = eval('(' + response + ')');
document.writeln(myArray.id);
document.writeln(myArray.name);
</script>
</head>
<body>
</body>
</html>
|
jemspitter
|
posted on 2/3/2010 at 10:58 AM |
HI
Here's what I'm trying to do: I have a php page I created on one domain,
that stores information in a database. Next, I have another web page (This
page is html NOT php) on a Different domain that I call this php page using
Javascript, and would like to return a variable from the php page. How is
this possible? I know it is, so don't say that it isn't!
|
|
|
|
|