Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
XML
<div id="sidebar-left"  href="" class="sidebar">
<a href="" class="new_project">New Project</a>
</div>



<div id="content">
        <div class="logo"><img src="My Four Wallls.png"><sup>Your Dashboard</sup></div>
        <div class="test"></div>
    </div>



I am clicking the menu in <pre>"sidebar-left</pre>" div and I need the PHP page to be displayed in the "test" div in side content.How can I do this?Please help me!
Posted
Updated 7-Nov-14 0:10am
v3

1 solution

Hello,

You can do the above thing, using AJAX call.

$('#sidebar-left').unbind('click').click(function(e){
    e.preventDefault();
    e.stopPropagation();

    // please provide the URL of the PHP page
    var url = 'app/php-page';

    $.post(url,
        function(data) {
            if ('' !== data) {
                // here data is the content of the whole php page
                // Inner HTML for php page content
                $('.test').empty().html(data);
            }
        }
    );
});


Hope this will help you. :)
 
Share this answer
 
Comments
Janardhanam Julapalli 7-Nov-14 23:59pm    
Thank You very much dude!It worked for me and You started my morning with some success.
Janardhanam Julapalli 8-Nov-14 0:00am    
Can u please tell me what this line of code will do
$('#sidebar-left').unbind('click').click(function(e){
Prava-MFS 8-Nov-14 0:06am    
Yes sure :). Glad that it helped you :).

You wanted the PHP page should be displayed on click of 'sidebar-left' menu click.

That's what I did :). I bind one click event for 'sidebar-left' div and before to that unbinding the click, if any. For example - first time, we bind the click event to 'sidebar-left' div, and second time, when we click on 'sidebar-left' div, the click event should work only once. So, for making this, I am unbinding the click event, and binding the click event again, to stop multiple click propagation :).
Janardhanam Julapalli 8-Nov-14 0:08am    
Thanks for the Explanation!
Janardhanam Julapalli 8-Nov-14 0:08am    
I Have used jQuery('#test').load('load.php').May I know why it does not work?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900