0

Example: I have written a php script like below:

<?PHP 
    function _hello(){  "Hello world!"; }
    function _bye(){  "Good Bye!"; }
    function _night(){  "Good Night!"; }
?>

<html>
    <head>!-- required files -- </head>  
    <body>
        <div id="thisDIV">
            <? echo _hello(); ?>
        </div>
        <div>
            This is another Division.
        </div>
    </body>
</html>

Is it possible that I just want to reload the function _hello() in the division (id=thisDIV) by using javascript? Or ajax, Jquery ajax or whatever.. How can I make it? Thanks!

2
  • 2
    For that you have to send ajax request with some parameters and at server side you can have logic to call function according to parameter value. Commented Dec 3, 2013 at 4:33
  • to echo something first of all return something from the functions function _hello(){ return "Hello world!"; } Commented Dec 3, 2013 at 4:34

1 Answer 1

2

You could add a querystring to your URL and then tie that to what function you want to run:

eg: http://myurl.com/page.php?function=hello

In page.php:

$function = $_GET['function'];

if($function == "hello") {
    hello();
}

etc etc

Sign up to request clarification or add additional context in comments.

1 Comment

@PaulLing Is that you expecting or something else ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.