View Full Version : ajaxed query seems to be caching...?!?! help needed plz

08-14-2008, 12:18 PM
:confused:Hi all,

im having some reliability issues with the following script called via ajax.

basically it should query the table, and bring a list back of ponumber(s) - the idea is then to give the user the option to select one of the used numbers or to use the newly generated number ($newponumber).

the problem is that there seems to be some form of caching issue somewhere. if the script works the first time it rarely works the 2nd time. it seems to fail to see any newly created ponumbers.

any ideas? if i load the php page itself it works all the time... but when called via ajax seems to be unreliable... which doesnt make sense to me.

im using the easywamp framework so its hosted on my test machine

$theid = $_REQUEST['theid'];
$query = "SELECT DISTINCT ponumber FROM poitems ORDER BY ponumber DESC";
$result = mysql_query($query);
$ponum = "";
$poflag = false;
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
if($poflag == false) {
$newponumber = $row['ponumber'] + 1;
$poflag = true;
$ponum = $ponum . "<a href='javascript:;' onclick=\"setPONum('ponumber$theid','{$row['ponumber']}','$theid')\">{$row['ponumber']}</a><br />\n";
echo "<div class='dropdown' style='width:116px;'>\n";
echo "<a href='javascript:;' onclick=\"setPONum('ponumber$theid','$newponumber','$theid')\">$newponumber</a> <strong>(New number)</strong><br />\n";
echo "$ponum<br />\n";
echo "<a href=\"javascript:;\" onclick=\"hidediv('ponumselector$theid')\">Close [x]</a>";
echo "</div>";

08-14-2008, 02:12 PM
I am not seeing any Ajax action on this code. Where are you using it?

08-14-2008, 03:00 PM
hi! yes, the code is JS that calls the PHP page.

function listPONums(podiv, theid) {

if (xmlHttp==null) {
alert ("Browser does not support HTTP Request");
var params = "?theid=" + theid;
var url="_list_ponums.php"
ajaxedInner = podiv;

function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

just a simple bit of script using a method that seems to work for everything else.

08-14-2008, 03:26 PM
with firefox go get firebug. you can watch the entire ajax transaction and see how the httpRequest is being formed, sent, and what is returned.

i'm not sure i like those echo's, but you'll be able to see if that's it when you see what it returns.

08-14-2008, 04:25 PM
i cant see anything wrong to be honest. its almost like the php ajax is calling is being cached somewhere... v odd.

whats wrong with the echos? its for a small system run internally on our network... maybe 5 or 6 users max. is using . notation much quicker? or am i missing something?

btw - tried all with one echo and . and still no luck.

i have even noticed that i can perform the same function on 2 different fields (basically if you click on a field it is supposed to ajax you back a list of purchase order numbers) and they CAN both return slightly different results!!!! that makes no sense at all to me!