469,329 Members | 1,495 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.

AJAX not refreshing

2
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
1 1735
Ukuser
2
Ignore me for now - am currently onto it and found why it may have happened!

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 #2

Post your reply

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

Similar topics

21 posts views Thread by javainfo | last post: by
reply views Thread by arunprabu | last post: by
4 posts views Thread by =?Utf-8?B?VW1lc2huYXRo?= | last post: by
25 posts views Thread by Piotr Nowak | last post: by
1 post views Thread by CARIGAR | 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.