473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem when refreshing DIV with jQuery

ilya Kraft
134 100+
Hello, I faced following problem. I have a div on a page which echoes out information from database. I want that div to refresh every 2 seconds, I found jQuery function that does this. but the problem is that content that needs to be refreshed has to be on different page. And this is where I cant figure it out. I will post here information that is currently on my page called "index.php", but I need to somehow move it to different page called "allposts.php" and include it in jQuery function
div has id="loaddiv" and new .PHP file needs to be named allposts.php.

here is jQuery function:
Expand|Select|Wrap|Line Numbers
  1. <script src="http://ajax.googleapis.com/ajax/
  2. libs/jquery/1.3.0/jquery.min.js"></script> 
  3.  <script> 
  4. var auto_refresh = setInterval(
  5. function()
  6. {
  7. $('#loaddiv').fadeOut('slow').load('allposts.php').fadeIn("slow");
  8. }, 2000);
  9. </script>
  10.  

here is script to collect information from database.

Expand|Select|Wrap|Line Numbers
  1. $sql_mem_data = mysql_query("SELECT id, username, firstname, lastname FROM myMembers WHERE id='$uid' LIMIT 1");
  2.     while($row = mysql_fetch_array($sql_mem_data)){
  3.             $uid = $row["id"];
  4.             $username = $row["username"];
  5.             $firstname = $row["firstname"];
  6.             $lastname = $row["lastname"];
  7.             if ($firstname != "") {$username = "$firstname $lastname"; } // (I added usernames late in  my system, this line is not needed for you)
  8.             ///////  Mechanism to Display Pic. See if they have uploaded a pic or not  //////////////////////////
  9.             $cacheBuster = rand(999999999,9999999999999);
  10.             $ucheck_pic = "members/$uid/image01.jpg";
  11.             $udefault_pic = "members/0/image01.jpg";
  12.             if (file_exists($ucheck_pic)) {
  13.             $blabber_pic = '<img style="border:#7cb815 1px solid; width:40px; height:40px;" src="' . $ucheck_pic . '?' . $cacheBuster . '" width="40px" border="0" />';  // forces picture to be 100px wide and no more
  14.             } else {
  15.             $blabber_pic = "<img style=\"border:#7cb815 1px solid;\" src=\"$udefault_pic\" width=\"40px\" height=\"40px\" border=\"0\" />"; // forces default picture to be 100px wide and no more
  16.             }
  17.  
  18.             $comentaryDisplayList .= '
  19.                   <div id="blablol"><table width="100%" align="center" cellpadding="4" style="border-bottom:#c8eb8c 1px solid;">
  20.         <tr>
  21.           <td width="7%" valign="top"><a href="profile.php?id=' . $uid . '">' . $blabber_pic . '</a>
  22.           </td>
  23.           <td width="93%" style="line-height:1.5em;" valign="top">
  24.          <span class="liteGreyColor textsize9"> ' . $whenComent . ' <a href="profile.php?id=' . $uid . '"><strong>' . $username . '</strong></a> <br />
  25.           via <em>' . $comment_device . '</em></span><br />
  26.          <span class="textsize10"> ' . $comment . '</span>
  27.             </td>
  28.         </tr>
  29.       </table></div>';
  30.             }
  31.  
  32.  
And here is how I echo out the information from database in div.

Expand|Select|Wrap|Line Numbers
  1. <div id="loaddiv" style="width:300px; overflow:hidden;">
  2. <?php echo "$comentaryDisplayList"; ?>
  3. </div>
  4.  
I need to make this database information auto refresh in id="loaddiv" div. I tried putting

Expand|Select|Wrap|Line Numbers
  1.  <?php echo "$comentaryDisplayList"; ?>
  2.  
in allcoments.php file, but it did not work. Any ideas how to make this work please?

Thank You.
Mar 31 '11 #1
0 1456

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Anil0920 | last post by:
I have a very serious problem which really needs to be solved. We had a huge number of projects in 2002 that we recently converted to VS.NET 2003. The conversion was smooth and all is working well....
3
by: Deacon | last post by:
Dear all, I am using DB2 for AIX, I have the following problem when migrating my DB from DB2 v7.2 to v8.1 I orginally have a table with a CLOB field with logged and not compact properties. We...
2
by: Palm Kevin | last post by:
Hello, I have a little problem when I try to use a class of a DLL. Example : I have a DLL with the object MTSync with a function Sync() I try in another program to use this dll like this :...
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
3
by: Ray Stevens | last post by:
I know there is a setting that will prevent screen flashing when refreshing a web page but cannot seem to find it. Can someone point me in the right direction?
9
by: darthghandi | last post by:
I am trying to create a server application using asynchronous sockets. I run into a problem when I try to connect to my server using a non-.net program. I can establish the connection, and send...
6
by: dawnerd | last post by:
Hello everyone. I have a question, or problem if you will, that I'm sure someone knows the answer to. I have a database that stores information on a given user. The information is stored in a...
1
by: =?Utf-8?B?bWF2cmljazEwMQ==?= | last post by:
Hi, I have a page which has some custom controls. The page works fine and doesn't break on any number of refreshes. There is button on the page, that starts a new child window. After doing any...
0
by: biplabdas | last post by:
" failed with the following error: " SQL0811N The result of a scalar fullselect, SELECT INTO statement, or VALUES INTO statement is more than one row. SQLSTATE=21000 I am facing the above...
25
pradeepjain
by: pradeepjain | last post by:
<html> <head> <script src="jquery.js" type="text/javascript"></script> <script src="jquery.rating.js" type="text/javascript" language="javascript"></script> <link...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.