shamsuljewel Posted November 24, 2007 Share Posted November 24, 2007 I have a friends list getting from database. When I click a link delete that call a ajax function name request3 which delete the specific data from the database...and show the information in top div. but in the below div the deleted data still remains unchanged cos the page didn't refreshed. so how do i do that the below div will also refreshed so that it shows the current data? any help please..?? Quote Link to comment Share on other sites More sharing options...
shamsuljewel Posted November 24, 2007 Author Share Posted November 24, 2007 can any one tell me how to refresh a div id of a page using ajax...? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 refresh a div, you have to write the new contents to the div contents just as you did on the page load , or remove the div in your case Quote Link to comment Share on other sites More sharing options...
shamsuljewel Posted November 24, 2007 Author Share Posted November 24, 2007 so how do i handle it? If i delete a list item i just want to reload the div. so that the update database info shows. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 If you post some of your code maybe I could give you a hand Quote Link to comment Share on other sites More sharing options...
shamsuljewel Posted November 24, 2007 Author Share Posted November 24, 2007 ok here is the code this is frnd_req.php file <DIV id="running"></DIV> <div id="req"> <table width="100%"> <?php $ro=0; if($total_pending > 0){ while($row = mysql_fetch_array($q_pending1)) { $q_search = "SELECT user_name,email,user_id FROM user_info WHERE id='$row[pending_user_id]'"; $q_search1 = mysql_query($q_search) or die(mysql_error()); $q_search2 = mysql_fetch_array($q_search1); //if($ro%2==0) $s_id = $row['s_id']; $query = "frnd_id=".$row[pending_user_id]."&s_id=".$s_id; $dt=date("M d, H:iA", $row['req_date']); echo "<tr>"; echo "<td><table width='100%' border='0'> <tr> <td height='65' rowspan='3' width='70'><div align='center'><img src='pic/images.jpg'/></div></td> <td width='200'>".mysql_result($q_search1,0,'user_name')."</td> <td rowspan='2' align='center'><a onClick=\"makeRequest3('add_frnds.php','running','$query');\" href='#'>Accept</a> | <a onClick=\"makeRequest3('invite_success.php','running','$query');\" href='#'>Reject</a></td> </tr>............................................ it shows some friends requests...now if accept is click then <a onClick=\"makeRequest3('add_frnds.php','running','$query');\" href='#'>Accept</a> add_frnds.php runs <?php session_start(); if($_SESSION['normal_user'] !="") { include("../dbconnect.php"); $id_me = mysql_fetch_array(mysql_query("SELECT id FROM user_info WHERE user_id='$_SESSION[normal_user]'")) or die(mysql_error()); $user_id = $id_me['id']; $tim = time(); if($_GET['frnd_id']) $frnd_id = $_GET['frnd_id']; //echo $frnd_id; if($_GET['s_id']) $s_id = $_GET['s_id']; //echo $s_id; $q_delete = "DELETE FROM frnd_pendinglist WHERE s_id='$s_id'"; $q_detele1 = mysql_query($q_delete) or die(mysql_error()); $q_add = "INSERT INTO frnd_list(user_id,frnd_id,create_date) VALUES('$user_id','$frnd_id','$tim')"; $q_add1 = mysql_query($q_add) or die(mysql_error()); $message = $frnd_id." is added to your friend list"; echo $message; } ?> so the message is shows in the running div. the database is changed..the accepted friend id is added to the friend list and from the pending table the request deleted. so now I want to reload the "req" div. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 Ok you'll have to add a tbody tag above the <tr> tag for each row, the tbody should have an id I would suggest something like "divreq_".$row[pending_user_id] which will give you a unique id when you make the ajax request in that function change the display property of that div to none that will hide the div hope its helpful Quote Link to comment Share on other sites More sharing options...
shamsuljewel Posted November 24, 2007 Author Share Posted November 24, 2007 can you please clear me the last sentense? "when you make the ajax request in that function change the display property of that div to none that will hide the div " Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.