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!
You cannot access a webpage (PHP or anything) residing on a different domain using Javascript. It's known as the same origin policy.
How do you call the PHP page? And you said that you succeeded to call the PHP page, so what is the problem?
When you try to embed another PHP, it should be on the same server. Otherwise it will embed the output.
You can not export scripts from a different server. This is actually can not be done with this, as far as i know. I think you better should consult it with someone expert.
Simple, you have to use AJAX...I do it all the time. Here is a brief explanation how it works.1. Create a servers side page (php, asp etc...) that does something clever like getting stuff from a database. The output of that page should be pure text, for example the page should just printout the variable value that you've mentioned without any html formating. In ASP you would use response.write() (not sure what it is in php)[br]2. In the html page that resides on a different server use an AJAX call in JavaScript to the page above[br]3. In the same Javascript capture the return value (that will be the text output I've mentioned in step 1)[br]4. do something in javascript with that valueNow...what is AJAX, well it's simply a XMLHttpRequest...if you can't be bothered coding a full XMLHttpRequest procedure you can use jQuery which can reduce the amount of coding on your side drastically...here's a simplejQuery example: function getRemoteValue{ var someValue = 100 //this is just to show that you can send variables to your remote page $.post("http://www.myremoteserver.com/getvalues.php", {ID: someValue }, //we rae using POST here, just like submitting a form function(data){ //data is the returned text content of your database page after the AJAX has finished setDefaults(data); // call another function that can deal with the data }); Code (markup): Hope this helps
If what you mean is to call some PHP function from another domain and retrieve the output than yes, you can make ajax request using javascript. but, if what you mean is to retrieve php script from another domain, than it is absolutely no, we just can't do that thing