Running PHP without a reload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JacobF
    New Member
    • May 2007
    • 1

    Running PHP without a reload

    Hi,

    Is there anything I can use to run a PHP function right out of the same file without a reload?
    AJAX seems to only be able to call a different file, and I only want one.

    Example:
    <? function myFunction(){.. .;} ?>
    <span onclick="php:my Function();">Ca ll Function</span>

    Thank you,
    Jacob
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, JacobF. Welcome to TSDN!

    Originally posted by JacobF
    Is there anything I can use to run a PHP function right out of the same file without a reload?
    AJAX seems to only be able to call a different file, and I only want one.
    AJAX can request any file, even the one that is at the same address that is currently loaded.

    However, PHP and JavaScript exist in two separate realms. PHP is server-side, and JavaScript is client-side. So you can't directly edit the contents of a page that is already loaded by using PHP, nor can you directly call a PHP function using JavaScript.

    On the other hand, you can use JavaScript to change the content of a page based on the result of the AJAX call (i.e., whatever the PHP script outputs), and you can pass parameters via GET or POST as part of your AJAX request that PHP can parse and use as arguments to a function.
    Last edited by pbmods; May 23 '07, 04:13 AM. Reason: s/call/request/

    Comment

    Working...