i got this php file 'check.php' that checks for changes ,and showing a counter for posts !! - $show_data="SELECT * FROM bidding_main WHERE bid_id='$bid_id' ";
-
$show_data_query=mysql_query($show_data);
-
$num_show_data=mysql_num_rows($show_data_query);
-
$sqlno="SELECT * FROM bidding_details WHERE bid_id=$bid_id ";
-
$queryno=mysql_query($sqlno);
-
echo "<table width='517' border='0' cellspacing='0' cellpadding='0'>";
-
echo " <tr>";
-
$rem=$max_bid-$numno;
-
if($rem<=0)
-
{
-
echo "0";
-
}
-
else
-
{
-
echo "<td bgcolor='#FFFFFF' align='center'><font color='red'><b>הצעות לסגירה: $rem </b></font></td>";
-
}"</td>";
-
echo "</tr>";
-
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 - function loadXMLDoc(url, callBack) {
-
if (window.XMLHttpRequest) {
-
req = new XMLHttpRequest();
-
req.onreadystatechange = callBack;
-
req.open("POST", url, true);
-
req.send(null);
-
} else if (window.ActiveXObject) {
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
if (req) {
-
req.onreadystatechange = callBack;
-
req.open("POST", url, true);
-
req.send();
-
}
-
}
-
}
-
-
-
-
-
-
function RefreshEngine( now)
-
{
-
var url="check.php"
-
if (now) url+='';
-
-
loadXMLDoc(url, RefreshResult;
-
-
}
-
-
-
-
function RefreshResult ()
-
-
{
-
-
//here im goint to have the second result
-
-
}
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
12 4351 acoder 16,027
Recognized Expert Moderator MVP
Just compare the responseText with wherever the content is output, or change your PHP code to output something else when (no) changes have been made.
how can i compare the response ,this is my problem ,i don't know how the pass the value from the php file ,how to get the right value to the ajax and compare the changes?
need little more help on that!!
thanx
acoder 16,027
Recognized Expert Moderator MVP
The output from the PHP file will be in req.responseText as a string. You can simply compare against whatever value you've already set: - if (req.responseText == "...") {
ok , im realy confused by this ajax and php thing ,i wan to make it short ,and i hope you can explain for me better!!
i got for example those two files
ajax.php
and ajax.js - function MakeRequest()
-
{
-
var xmlHttp = getXMLHttp();
-
-
xmlHttp.onreadystatechange = function()
-
{
-
if(xmlHttp.readyState == 4)
-
{
-
HandleResponse(xmlHttp.responseText);
-
}
-
}
-
-
xmlHttp.open("GET", "ajax.php", true);
-
xmlHttp.send(null);
-
}
-
-
function HandleResponse(response)
-
{
-
document.getElementById('ResponseDiv').innerHTML = response;
-
}
-
my quastion is , after i excute this script and the response is showing me "10" ,if after i change the php file to "11" or any thing else ,does the ajax will execute another function() if it sees that there is a change in the php file?
this is how i want it to be :
ajax is checking a php file for changes ,and if is is changed execute another function!!
thanx
acoder 16,027
Recognized Expert Moderator MVP
In HandleResponse(), document.getElementById('ResponseDiv').innerHTML contains the old value and response contains the new value, so compare them: - if (document.getElementById('ResponseDiv').innerHTML == response) {
-
// value hasn't changed...
-
} else {
-
// value has changed...
-
}
is this correct? - function MakeRequest()
-
{
-
var xmlHttp = getXMLHttp();
-
-
xmlHttp.onreadystatechange = function()
-
{
-
if(xmlHttp.readyState == 4)
-
{
-
HandleResponse(xmlHttp.responseText);
-
}
-
}
-
-
xmlHttp.open("GET", "ajax.php", true);
-
xmlHttp.send(null);
-
-
setTimeout('MakeRequest()', 4000);
-
}
-
-
-
-
-
-
-
function HandleResponse(response)
-
{
-
-
if (document.getElementById('ResponseDiv').innerHTML == response)
-
{
-
-
alert ("something changed");
-
-
}
-
-
else
-
-
{
-
-
alert ("nothing changed");
-
-
}
-
-
-
}
acoder 16,027
Recognized Expert Moderator MVP
It would be except that the Response Div must be set first in another request or during page load.
can you please please correct my wrongs, im geting crazy !!
acoder 16,027
Recognized Expert Moderator MVP
What's the ResponseDiv div initially set to?
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!
this one is working for me heheheheeeh - function MakeRequest()
-
{
-
var xmlHttp = getXMLHttp();
-
-
xmlHttp.onreadystatechange = function()
-
{
-
if(xmlHttp.readyState == 4)
-
{
-
HandleResponse(xmlHttp.responseText);
-
}
-
}
-
-
xmlHttp.open("GET", "ajax.php", true);
-
xmlHttp.send(null);
-
setTimeout('MakeRequest()', 4000);
-
}
-
-
-
-
function HandleResponse(response)
-
{
-
if (document.getElementById('ResponseDiv').innerHTML == response)
-
{
-
-
-
-
}
-
-
else if (document.getElementById('ResponseDiv').innerHTML = response)
-
-
{
-
-
-
alert("something as changed")
-
}
-
-
}
acoder 16,027
Recognized Expert Moderator MVP
It works, but probably not in the way you intended. The line - 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: - if (document.getElementById('ResponseDiv').innerHTML != response)
-
{
-
document.getElementById('ResponseDiv').innerHTML = response;
-
alert("something as changed")
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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
|
by: hockeyham |
last post by:
Is this possible... :)~
--------------------------------------------------------------------------------
Hello...
Please see this post HTML Question
The answer was to try AJAX... to be...
|
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...
| |
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...
|
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...
|
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...
|
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,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |