|
XMLHttpRequest problem
Hi everyone,
hope someone can help because i can't understand why it doesn't work.
i have this function to load a php file.
function php_load(file,id,id_target) {
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if(id == 0){
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4){
document.getElementById(id_target).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET",file,true);
xmlhttp.send();
}
else if(id == 1){
xmlhttp.open("GET",file,false);
xmlhttp.send();
return xmlhttp.responseText;
}
}
the id parameter can be 0 or 1 and identify if i want to write inside the innerHTML of a DIV (0) or if i just want to receive a value (1).
everything is ok normally.. for example I can use the function to add a row in my database and the row is correctly added.
The problem is that if i wanna update a table with the new row and i call the function load_php the table is loaded but with old data and not with the new row.
to be able to load the new data i have to close all browser pages and load from beginnig all my project. Even though i refresh the page it doesn't work.
i don't know if it's a problem of some cache or something... i can't understand why new data are not loaded simply calling the function..
Anyone has an answer to my problem??
thanks everyone!!
|