469,329 Members | 1,380 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,329 developers. It's quick & easy.

Updating area

Hi Folks,

I havent used javascript in ages, and am not the worlds guru, but I'm
playing with ajax linking to my database and an updating area.

I have an area named display for example which lists each entry (from
a PHP/MySQL db) with a remove button at the end of each record which
feeds a unique ID to my ajaxfunction below:

function ajaxFunction(rec){
var aR;
try{
aR = new XMLHttpRequest();
} catch (e){
try{
aR = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
aR = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser broke!");
return false;
}
}
}
aR.onreadystatechange = function(){

if(aR.readyState == 4){
var aD = document.getElementById('test').innerHTML =
aR.responseText;
}
}
aR.open("GET", "delete.php?del="+rec+"&sid="+Math.random(), true);
aR.send(null);
}

My problem is that although delete.php correctly displays the updated
list of entries (the first time), if I reclick Remove (which is re-
displayed by delete.php) whatever I have tried does not update the
list again (although it does remove the record from the db). Its like
the function needs resetting.

I sometimes get told to be clear - so I'll retry just in case
php - get data & display as rows in display area
(field - field - Remove button onclick(ajaxFunction(unique ID)) -
etc etc
<display area</da>
delete.php deletes the row and redisplays the php data into the
display area. It redisplays the options with a delete button but when
clicked - although the data IS removed from the DB the display area
does not refresh with the new updated data.

I hope that makes sense, and any help would be great. I'm tempted to
give up and just use static old PHP .... never fails.

Thanks

A

Mar 29 '07 #1
2 1456
On 29 Mar, 14:07, "UKuser" <spiderc...@yahoo.co.ukwrote:
Hi Folks,

I havent used javascript in ages, and am not the worlds guru, but I'm
playing with ajax linking to my database and an updating area.

I have an area named display for example which lists each entry (from
a PHP/MySQL db) with a remove button at the end of each record which
feeds a unique ID to my ajaxfunction below:

function ajaxFunction(rec){
var aR;
try{
aR = new XMLHttpRequest();
} catch (e){
try{
aR = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
aR = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser broke!");
return false;
}
}
}

aR.onreadystatechange = function(){

if(aR.readyState == 4){
var aD = document.getElementById('test').innerHTML =
aR.responseText;
}}

aR.open("GET", "delete.php?del="+rec+"&sid="+Math.random(), true);
aR.send(null);

}

My problem is that although delete.php correctly displays the updated
list of entries (the first time), if I reclick Remove (which is re-
displayed by delete.php) whatever I have tried does not update the
list again (although it does remove the record from the db). Its like
the function needs resetting.

I sometimes get told to be clear - so I'll retry just in case
php - get data & display as rows in display area

(field - field - Remove button onclick(ajaxFunction(unique ID)) -
etc etc
<display area</da>

delete.php deletes the row and redisplays the php data into the
display area. It redisplays the options with a delete button but when
clicked - although the data IS removed from the DB the display area
does not refresh with the new updated data.

I hope that makes sense, and any help would be great. I'm tempted to
give up and just use static old PHP .... never fails.

Thanks

A
firstly use POST when changing the state of the app/database, (or for
instance all your links could all be prefetched, killing the entire
thing)

secondly, if you are not already using firebug in firefox, install it,
you can watch your XHR calls in real time, and debug everything to do
with ajax easily. Using a proxy would also help, so get fiddlertool or
paros. This will help YOU see exactly what's going on without needing
any help from anyone, trust me.

Mar 29 '07 #2
On 29 Mar, 14:49, "shimmyshack" <matt.fa...@gmail.comwrote:
On 29 Mar, 14:07, "UKuser" <spiderc...@yahoo.co.ukwrote:
Hi Folks,
I havent used javascript in ages, and am not the worlds guru, but I'm
playing with ajax linking to my database and an updating area.
I have an area named display for example which lists each entry (from
a PHP/MySQL db) with a remove button at the end of each record which
feeds a unique ID to my ajaxfunction below:
function ajaxFunction(rec){
var aR;
try{
aR = new XMLHttpRequest();
} catch (e){
try{
aR = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
aR = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser broke!");
return false;
}
}
}
aR.onreadystatechange = function(){
if(aR.readyState == 4){
var aD = document.getElementById('test').innerHTML =
aR.responseText;
}}
aR.open("GET", "delete.php?del="+rec+"&sid="+Math.random(), true);
aR.send(null);
}
My problem is that although delete.php correctly displays the updated
list of entries (the first time), if I reclick Remove (which is re-
displayed by delete.php) whatever I have tried does not update the
list again (although it does remove the record from the db). Its like
the function needs resetting.
I sometimes get told to be clear - so I'll retry just in case
php - get data & display as rows in display area
(field - field - Remove button onclick(ajaxFunction(unique ID)) -
etc etc
<display area</da>
delete.php deletes the row and redisplays the php data into the
display area. It redisplays the options with a delete button but when
clicked - although the data IS removed from the DB the display area
does not refresh with the new updated data.
I hope that makes sense, and any help would be great. I'm tempted to
give up and just use static old PHP .... never fails.
Thanks
A

firstly use POST when changing the state of the app/database, (or for
instance all your links could all be prefetched, killing the entire
thing)

secondly, if you are not already using firebug in firefox, install it,
you can watch your XHR calls in real time, and debug everything to do
with ajax easily. Using a proxy would also help, so get fiddlertool or
paros. This will help YOU see exactly what's going on without needing
any help from anyone, trust me.
Firebug is excellent and well worth downloading. Good advice and
helped fix my code!

Mar 29 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by dave | last post: by
3 posts views Thread by Basil Fenix | last post: by
3 posts views Thread by Steve Lamb | last post: by
14 posts views Thread by el_sid | last post: by
3 posts views Thread by Grant | last post: by
3 posts views Thread by RSH | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.