Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    518
    Thanks
    25
    Thanked 0 Times in 0 Posts

    ajaxed query seems to be caching...?!?! help needed plz

    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

    PHP Code:
    $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($resultMYSQL_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";
    }
    mysql_free_result($result);
    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>"
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #2
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    I am not seeing any Ajax action on this code. Where are you using it?

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    518
    Thanks
    25
    Thanked 0 Times in 0 Posts
    hi! yes, the code is JS that calls the PHP page.

    [script]
    function listPONums(podiv, theid) {

    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null) {
    alert ("Browser does not support HTTP Request");
    return;
    }
    var params = "?theid=" + theid;
    var url="_list_ponums.php"
    url=url+params;
    ajaxedInner = podiv;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    }

    function stateChanged() {
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
    document.getElementById(ajaxedInner).innerHTML=xmlHttp.responseText;
    }
    }

    [/script]

    just a simple bit of script using a method that seems to work for everything else.
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #4
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    518
    Thanks
    25
    Thanked 0 Times in 0 Posts
    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!
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •