php - How to refresh different div in same page -
i using php
, mysql
database website.
in website have four
different menu. in each menu have single div has refresh after clicking it.
here refresh mean call php file has functionality insert,delete , display specific contain database.
my code refreshing whole page instate of div refresh.
here sample code:
my mainpage.php
<div> <ul id="headermenu" class="menu"> <li rel="menu1"><a href="" >about</a></li> <li rel="menu2"><a href="" class="">display</a></li> <li rel="menu3"><a href="" class="">settings</a></li> </ul> </div> <div id="menu1" class="menu_content"> <div class="right-pane"> <div class="details"> <?php include('about.php'); ?> </div> <div id="menu2" class="menu_content"> <div class="right-pane"> <div class="details"> <?php include('display.php'); ?> </div> <div id="menu3" class="menu_content"> <div class="right-pane"> <div class="details"> <?php include('settings.php'); ?> </div>
my display.php
<?php /* fetched latest data database done */ /* if use header going main page div */ ?>
now want display data in display div.
can 1 please tell me how achieve this?
thank you.
now try code.
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $( "button[class='disp']" ).click(function() { $(".details").load('profile.php'); }); }); </script> </head> <body> <div> <ul id="headermenu" class="menu"> <li rel="menu1"><button>about</button></li> <li rel="menu2"><button class="disp">display</button></li> <li rel="menu3"><button>settings</button></li> </ul> </div> <div id="menu1" class="menu_content"> <div class="right-pane"> <div class="about"> <?php //include('about.php'); ?> </div> </div> <div id="menu2" class="menu_content"> <div class="right-pane"> <div class="details"> <?php include('profile.php'); ?> </div> </div> </div> <div id="menu3" class="menu_content"> <div class="right-pane"> <div class="settings"> <?php //include('settings.php'); ?> </div> </div> </div> </div> </body> </html>
just add profile.php that.
<?php echo rand(1, 9999); ?>
do not forget add jquery. http://jquery.com/download/
hope you.
thanks
Comments
Post a Comment