1

I'm currently working on a website and I would like to be able to do the following:

  • when clicking one of the links from the sideMenu the only thing I would like to change would be the content of my contentMain div and nothing else(page layout/design/etc)

Could anybody give me some general pointers on how I could achieve this in php?

Thank You in advance :D

2
  • Definitely look into using Ajax as it is perfect for things like this. Commented Jul 18, 2012 at 17:56
  • Ajax, jQuery, Javascript are your friends - api.jquery.com/load Commented Jul 18, 2012 at 17:57

3 Answers 3

2

This is a client-side change that cannot be accomplished using PHP. PHP is evaluated on the server-side, so once the page is loaded for the user, it has no control over what the user sees (unless you use client-side code to call PHP).

To accomplish this, you will need to use Javascript and/or jQuery.

Reference: https://developer.mozilla.org/en/JavaScript/

jQuery: http://jquery.org/

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

1 Comment

Or Prototype, or mootools, or... (+1, btw)
1

iFrame, frameset or AJAX all work for your case depending on what you are actually trying to achieve.

For AJAX calls (the most modern way out of the three that relies on Javascript) you can use a library such as jQuery.

http://api.jquery.com/category/ajax/

Comments

1

You can use ajax for this one. Using jQuery to detect the click on the link or use normal JavaScript onClick function. Then do the things like you want.

<a href="" id="my_link">My link<a>

<script type="text/javascript">
   jQuery(document).ready(function(){
         jQuery('#my_link').click(function(){
            jQuery.ajax({
                url: 'ajax page need to be called',
                success: function(data) {
                     //do your operations on success
                }
           });
         });
   });
</script>

You can get more details on :

jQuery jQuery Ajax

Hope this helps you

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.