How do I use php code from a different domain?


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

One Response to “How do I use php code from a different domain?”

  • Kris:

    Ok, this makes marginally more sense. So, you want your PHP to return a variable to the JavaScript? Try a hidden field:
    <input id="myHiddenField" value="myValue" type="hidden" hidden/>

    and the js:
    var value = document.getElementById(‘myHiddenField’).value;

    if that is not the case, if you are trying to get a JS variable into PHP, that cannot be done.

    PHP is a server side language, which means the code is DONE by the time the web page is displayed. JavaScript is a client side language, which means the code is executed ONCE THE PAGE IS LOADED.

    Communication between client-side and server-side languages is limited, and one way (server-side->client-side via hidden field [crude]). I suggest you rethink your method…

Leave a Reply