externalInterface and ajax, old xml loads not new

  • chopficaro
  • Novice
  • Novice
  • chopficaro
  • Posts: 30

Post 3+ Months Ago

I've used ExternalInterface.call for an onclick flash event to load some xml with XMLHttpRequest. the xml loads. but if i change the xml file on the server, the old xml file loads for the client, not the new one. i believe the problem is that the browsers are caching the results. i heard that this could usually be fixed by returning false from ur JavaScript onclick handler. but i dont have a JavaScript onclick handler, i have a flash onclick handler.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

what's generating the xml? If you can try moving to something serverside that generates the xml as a result of an http request. Then point your XMLHttpRequest to that so get myresults.php that returns xml content instead of trying to get something like myresults.xml

Its been my experience that most browsers heavily cache xml and I've never found a solid way around it other than to generate the xml on the fly.
  • chopficaro
  • Novice
  • Novice
  • chopficaro
  • Posts: 30

Post 3+ Months Ago

i know some php but im not quite following. ur saying

myajax.open("GET", "myresults.php", true); ????

what would myresults.php look like?
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Can you post some code? I'm not entirely clear on what your trying to do but basically what I'm suggesting is that you build a function in your serverside language of choice (php, .net, jsp, ruby, etc) that returns the xml data as the result of the function. This will mean that the xml is always dynamic and won't ever be cached by the browser.
  • chopficaro
  • Novice
  • Novice
  • chopficaro
  • Posts: 30

Post 3+ Months Ago

everything is in the directory above the site patiscool . 000a . biz/yankeesitev1.2/width%20relative%20to%20height%20working.htm

but heres the line in the funbutton . as file that calls the javascript function

ExternalInterface.call("makeRequest", text_txt.text);

and here is the javascript functions

Code: [ Select ]
function makeRequest(lableText)
{
    if (window.XMLHttpRequest)
    {
        xhr = new XMLHttpRequest();
    }
    else
    {
        if (window.ActiveXObject)
        {
            try
            {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) { }
        }
    }

    if (xhr)
    {
        xhr.onreadystatechange = showContents;
        xhr.open("GET", lableText + ".xml", true);
        document.getElementById('contentpre').innerHTML = lableText + ".xml";
        xhr.send(null);
    }
    else
    {
        document.getElementById('contentpre').innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
    }
    return false;
}

function showContents()
{
    if (xhr.readyState == 4)
    {
        if (xhr.status == 200)
        {
            var outMsg = xhr.responseText;
        }
        else
        {
            var outMsg = "There was a problem with the request. State is " + xhr.readyState + " status is " + xhr.status;
        }
        document.getElementById('contentpre').innerHTML = outMsg;
    }
    return false;
}
  1. function makeRequest(lableText)
  2. {
  3.     if (window.XMLHttpRequest)
  4.     {
  5.         xhr = new XMLHttpRequest();
  6.     }
  7.     else
  8.     {
  9.         if (window.ActiveXObject)
  10.         {
  11.             try
  12.             {
  13.                 xhr = new ActiveXObject("Microsoft.XMLHTTP");
  14.             }
  15.             catch (e) { }
  16.         }
  17.     }
  18.     if (xhr)
  19.     {
  20.         xhr.onreadystatechange = showContents;
  21.         xhr.open("GET", lableText + ".xml", true);
  22.         document.getElementById('contentpre').innerHTML = lableText + ".xml";
  23.         xhr.send(null);
  24.     }
  25.     else
  26.     {
  27.         document.getElementById('contentpre').innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
  28.     }
  29.     return false;
  30. }
  31. function showContents()
  32. {
  33.     if (xhr.readyState == 4)
  34.     {
  35.         if (xhr.status == 200)
  36.         {
  37.             var outMsg = xhr.responseText;
  38.         }
  39.         else
  40.         {
  41.             var outMsg = "There was a problem with the request. State is " + xhr.readyState + " status is " + xhr.status;
  42.         }
  43.         document.getElementById('contentpre').innerHTML = outMsg;
  44.     }
  45.     return false;
  46. }
  • chopficaro
  • Novice
  • Novice
  • chopficaro
  • Posts: 30

Post 3+ Months Ago

i got it, check it out
xhr.open("GET", lableText + ".xml"+"?"+(new Date()).getTime(), true);

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.