Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flash externalInterface and ajax, old xml loads not new

Status
Not open for further replies.

chopficaro

Programmer
May 10, 2008
11
US
I've used a flash 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.
 
Is there anyway you can add a parameter to the end of the call to the xml file?

I remember years ago I built a site using classic asp and we had a similar issue with old CSS files being loaded - whenever we updated the css, the old one was still cached, so to get around it we did this:

Code:
<link rel="stylesheet" type="text/css" href="default.css[COLOR=red]?a=<%=now%>"[/color] />

Essentially, a the css would get re-loaded as the file name was "different" - once we were finished development and put the code into production, we took out the parameter and let the browser do it's own thing with caching.




--------

GOOGLE is a great resource to find answers to questions like "how do i..."


--------
 
someone said i need to generate the xml on the fly with php. i know some php but im a little confused. i think hes saying

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

what would myresults.php look like?
 
here's a simple one:

Code:
<?php
header('Content-type: text/xml; charset = ISO-8859-1');

$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
$xml .= "<continent name=\"north_america\">\n";
$xml .= "<country>Canada</country>\n";
$xml .= "<country>USA</country>\n";
$xml .= "<country>Mexico</country>\n";
$xml .= "</continent>\n";

echo $xml;
?>


--------

GOOGLE is a great resource to find answers to questions like "how do i..."


--------
 
>myajax.open("GET", "myresults.php", true);
Add to query something quite different each time, such as this.
[tt]myajax.open("GET", "myresults.php"[blue]+"?"+(new Date()).getTime()[/blue], true); [/tt]
 
>myajax.open("GET", "myresults.php", true);
Add to query something quite different each time, such as this.
myajax.open("GET", "myresults.php"+"?"+(new Date()).getTime(), true);

people keep telling me this but i dont understand! i dont have 1 file for every time of the day! i only have myresults.xml i dont have myresults.xml54353 and myresults.xml43242! how will it find my file when theres extra stuff at the end of the name???
 
That is one possible realization. You have one file myresults.php and that is exactly the point. You have not or even are not in a position to execute the line?
 
ok i got it now, the other guys forget to tell me about the +"?"+ between the name and the number

xhr.open("GET", lableText + ".xml"+"?"+(new Date()).getTime(), true);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top