Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That's not how PHP works. You're making a common thinking error, that a lot of beginners make, in that you seem to think that a <a href="http://en.wikipedia.org/wiki/Client_%28computing%29" rel="nofollow">client-side</a> language like Javascript, can interact with a <a href="http://en.wikipedia.org/wiki/Server_%28computing%29" rel="nofollow">server-side</a> language, such as PHP, in this fashion. This is due to a misunderstanding of the <a href="http://en.wikipedia.org/wiki/Client%E2%80%93server_model" rel="nofollow">client/server</a> and/or <a href="http://en.wikipedia.org/wiki/Request-response" rel="nofollow">request/response</a> model.</p> <p>When you request a web page with your browser (the client), your request is processed by the webserver (the server), that then returns a response, basically like this:</p> <pre><code> Client (browser) Server (webserver) --------------------------------------------------- Send page request -----&gt; Parse request (execute PHP) | \|/ Parse HTML response &lt;----- Send HTML response (and execute (there will be no Javascript, more PHP code in if that was part this response) of the response) </code></pre> <p>In other words: the client and server are two completely separated processes, that only communicate with each other based on a request/response principle.</p> <p>PHP cannot be executed on the client-side (save for the client-side version PHP-GTK, which we are not discussing here), and Javascript cannot be executed on the server-side (save for server-side versions of Javascript, which we are not discussing here). So, the PHP function <code>domaincheck</code> will not be available for the client to call, and the Javascript calls will not be received by the server.</p> <p>And so, if you don't want to request a complete web page again, but merely have a Javascipt function request and receive the output of a PHP function, you'd have to let Javascipt make another request to the server again ('in the background', meaning: without completely replacing the whole page in the browser), and have PHP create a response again, this time with output that Javascript can handle. This is typically known as <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="nofollow">AJAX</a> (Asynchronous JavaScript and XML). Although the response doesn't have to be XML. A <a href="http://en.wikipedia.org/wiki/JSON" rel="nofollow">JSON</a> response is very common. Fragments of HTML (or even complete HTML pages) are also possible.</p> <p><em>I'll probably add an example for you at some point in the near future.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload