nutritionmaster asked:
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 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! (10 points for the person that finally answers this question!)
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 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! (10 points for the person that finally answers this question!)


3 Comments to 'How do I use php code from a different domain?'
February 9, 2010
You use PHP on the “server-side” to get the data and bring it over.
Site A - has php and holds the data
Site B - is the site that “wants” the data
On Site B create a simple PHP page that uses (http://us3.php.net/curl) PHP Curl library to GET or POST data over HTTP from the server side from Site A.
Then this same PHP page can display the data in whatever format you like. Now you can have a simple HTML/Javascript page that can access this PHP page on Site B - (which is doing the server side connection to Site A)
Hope you followed that, but simply you are making a simple PHP proxy page.
February 10, 2010
If your referring to Ajax, it will not let you send calls to another domain (security feature). Period.
If I understand correctly, you are trying this:
PHP page (domain1) -> javascript call to PHP page (domain2)
If that is what you are trying to do, that is NOT possible.
If you would try something like
PHP page (domain1) PHP page(domain2)
That IS possible with cURL
but no JS intermediary….
February 11, 2010
with javascript just do something like
echo “window.location=\”http://yoursite.com?I_Will_Be_Passed=$PHP_Variable\”";
Leave a comment