0

Hello I am trying to handle Nav bar where are 4 buttons and on click I would like to include another php file into same one.

My nav bar look like this:

<body>

    <div id="dock-container">
        <div id="dock">
        <ul>


            <li><span>Sony Ericsson</span><?php include ('menu.php') ?>"<img src="3.png"/></a></li>
      <li><span>test</span><a href="http://sonyericsson.com"><img src="4.jpg"/></a></li>
       <li><span>test</span><a href="http://sonyericsson.com"><img src="1.png"/></a></li>
        <li><span>test</span><a href="http://sonyericsson.com"><img src="2.jpg"/></a></li>


        </ul>
        <div class="base"></div>
        </div>
    </div>

and file which should be include is

<?php

echo "Ahoj";

?>

Thanks for help

1

1 Answer 1

1

To accomplish this you need to make an AJAX request. There are plenty of ways to do this but using jQuery ajax() Method would be the easiest. You can implement something like this.

$("#click_button").click(function(){
    $.ajax({url: "URL_TO_YOUR_PHP_FILE", success: function(result){
        $("#fourth_button").html(result);
    }});
});

PS: replace URL_TO_YOUR_PHP_FILE with the actual URL of your actual file for e.g http://example.com/includes/file.php

Thanks

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

Comments

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.