473,566 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem when refreshing DIV with jQuery

ilya Kraft
134 New Member
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.p hp" 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 1463

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

Similar topics

0
1382
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. How-ever when we make any change to a form and save the form using VS.NET 2003, it reorganizes all form elements and the width / height of text...
3
2771
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 I use db2look to obtain the structure, the following is the output: CREATE TABLE "TEST"."TEST1" (
2
2114
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 : MTSync sync = new MTSync(); sync.Sync(); OK, now the problem: The problem is NOT that this does not work, it works great, it does everything it has...
5
2574
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 date, name, address etc) about the selected row in the datagrid... My problem is when I enter a new record in the details tabpage (saves data...
3
2990
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
4286
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 some packets in response to the programs first message, but when I receive a response back, it's the last packet I sent. After that packet, I...
6
2987
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 serialized array. This works flawlessly when using only single line text. When I tried to store multiline text, the problem arose. When the...
1
1280
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 thing or nothing, when the user clicks the 'close' button I want to refresh the parent window. It works a few times than the parent window goes...
0
1281
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 problem when I tried to refresh a table which is created by Materialized View... Please help..
25
5144
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 href="jquery.rating.css" type="text/css" rel="stylesheet"/> <link rel="stylesheet" type="text/css" href="style.css"> <script...
0
7666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8108
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.