473,806 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX , check for changes and do refresh!!

155 New Member
i got this php file 'check.php' that checks for changes ,and showing a counter for posts !!

Expand|Select|Wrap|Line Numbers
  1. $show_data="SELECT * FROM bidding_main WHERE bid_id='$bid_id' ";
  2. $show_data_query=mysql_query($show_data);
  3. $num_show_data=mysql_num_rows($show_data_query);
  4.         $sqlno="SELECT * FROM bidding_details WHERE bid_id=$bid_id ";
  5. $queryno=mysql_query($sqlno);
  6.         echo "<table width='517' border='0' cellspacing='0' cellpadding='0'>";
  7.         echo "    <tr>";
  8.          $rem=$max_bid-$numno;
  9.                         if($rem<=0)
  10.                         {
  11.                         echo "0";
  12.                         }
  13.                         else
  14.                         {
  15.                         echo "<td bgcolor='#FFFFFF' align='center'><font color='red'><b>הצעות לסגירה: $rem </b></font></td>";
  16.                         }"</td>";
  17.         echo "</tr>";
  18.         echo "</table>";
now, i cannot figure it out in ajax how to point the request to check if something as changed when the php file is executed?

how do i get the ajax to check that something as changed?

here is my starting ajax file

Expand|Select|Wrap|Line Numbers
  1. function loadXMLDoc(url, callBack) {
  2.     if (window.XMLHttpRequest) {
  3.         req = new XMLHttpRequest();
  4.         req.onreadystatechange = callBack;
  5.         req.open("POST", url, true);
  6.         req.send(null);
  7.     } else if (window.ActiveXObject) {
  8.         req = new ActiveXObject("Microsoft.XMLHTTP");
  9.         if (req) {
  10.             req.onreadystatechange = callBack;
  11.             req.open("POST", url, true);
  12.             req.send();
  13.         }
  14.     }
  15. }
  16.  
  17.  
  18.  
  19.  
  20.  
  21. function RefreshEngine( now)
  22. {  
  23.      var url="check.php"
  24.      if (now) url+='';
  25.  
  26.      loadXMLDoc(url, RefreshResult;
  27.  
  28. }
  29.  
  30.  
  31.  
  32. function RefreshResult ()
  33.  
  34. {
  35.  
  36.     //here im goint to have the second result
  37.  
  38. }
please help me out with this ,it's a week that im serching for result for this ,i tryed million of combinations ,and no success !!

please help or point me to the right direction!!

thanx
Nov 16 '08
12 4387
canabatz
155 New Member
it's reading this php file


i just want it to check if the php file as changed

<?

echo "10";

?>


i want to be able to change it by hend to 11 and it will alert me that something changed!
Nov 18 '08 #11
canabatz
155 New Member
this one is working for me heheheheeeh

Expand|Select|Wrap|Line Numbers
  1. function MakeRequest()
  2. {
  3.   var xmlHttp = getXMLHttp();
  4.  
  5.   xmlHttp.onreadystatechange = function()
  6.   {
  7.     if(xmlHttp.readyState == 4)
  8.     {
  9.       HandleResponse(xmlHttp.responseText);
  10.     }
  11.   }
  12.  
  13.   xmlHttp.open("GET", "ajax.php", true); 
  14.   xmlHttp.send(null);
  15.   setTimeout('MakeRequest()', 4000);
  16. }
  17.  
  18.  
  19.  
  20. function HandleResponse(response)
  21. {
  22.   if (document.getElementById('ResponseDiv').innerHTML == response)
  23.     {
  24.  
  25.  
  26.  
  27.     }
  28.  
  29. else if (document.getElementById('ResponseDiv').innerHTML = response)
  30.  
  31.     {
  32.  
  33.  
  34. alert("something as changed")
  35.     }
  36.  
  37. }
Nov 18 '08 #12
acoder
16,027 Recognized Expert Moderator MVP
It works, but probably not in the way you intended. The line
Expand|Select|Wrap|Line Numbers
  1. else if (document.getElementById('ResponseDiv').innerHTML = response)
will always be true because you always set the innerHTML and the result is true.

A more meaningful version would be something like:
Expand|Select|Wrap|Line Numbers
  1. if (document.getElementById('ResponseDiv').innerHTML != response)
  2.     {
  3.     document.getElementById('ResponseDiv').innerHTML = response;
  4.     alert("something as changed")
  5.     }
Nov 19 '08 #13

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

Similar topics

3
3886
by: | last post by:
Hello, I have a ListView control in Details view. When an item is un-checked, I want to change the ForeColor. The only way I have found to do this is to loop through all the items of the ListView in its Click, DoubleClick, and KeyPress events using the sub below .. However, the ListView can potentially hold hundreds of items, so this would be quite slow.
3
2909
by: Beshoo | last post by:
hey gaiz plz I want to cerate log in system in ajax i do it but i have one problem AFTER I start thes session then press refresh key the session gone !!! in other words , after the user type hid username and password I send this information by XMLrequest to php file which verify the user name and the password if trure open the sesstion and get it name 'user' its become like this $_SESSION=$user;
1
1348
by: lauralaura | last post by:
Hallo ! is there in Java a clever method, which checks the changes in a database every 30 sec and after that it shows these changes? thanks alot.. Laura
3
5720
by: hockeyham | last post by:
Is this possible... :)~ -------------------------------------------------------------------------------- Hello... Please see this post HTML Question The answer was to try AJAX... to be honest I can't find much about how to use AJAX. Does anyone have any time to help develope some code to use on my site? Or point me to a site that has AJAX code I can see and try to develope to do what I want it too? Thanks for the help!
0
1264
by: Gimble | last post by:
Does anyone know of a way to detect when an AJAX call has finished updating a page in the webbrowser control in a vb.net program? For example, if I click "next" on a page and that causes a table on the page to reload, is there a way to know when that page section has finished loading?
3
5560
by: burrashiva | last post by:
:( ::) Hello there, I recently started Web Designing with PHP, Javascript and AJAX. I am facing a problem which I will try to explain: If I am successful in conveying the problem to you clearly, could you pl. suggest me some solution? Thank you, Here is the problem details:
7
2440
by: raknin | last post by:
I'm using AJAX on my website, but internet explorer does not seem to actually be refreshing the data I retrieve via AJAX when I refresh the page. For example, I have a button that when pressed uses an XMLHttpRequest to go read some data from a database then returns it to the browser for display. It looks like: Press button XMLHttpRequest gets data from db XMLHttpRequest renders returned data in client browser I can update the...
4
5290
kelleyvanevert
by: kelleyvanevert | last post by:
Hello everyone, This question is often asked, and I know there are lots and lots of answers that I could be using, but I just want a clear good answer. I am making a website (for playing a game called Go). It has a page for each game of course. I'm making the website in PHP and MySQL, I know that for 'real-time' games another solution would probably be better, but I'm learning to master php and MySQL. The game is shown via the <canvas>...
2
1458
by: Chris | last post by:
I'm developing an ASP.NET Page that processes some files, does some things to them. I'd like to have a gridview that displays each file, and it's status, if it's done processing, still processing, etc. The page runs for about a minute per file, so I was hoping I could use an AJAX UpdatePanel control to refresh the gridview as a file is done being processed. Is this doable?
0
9719
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4329
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

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.