Hi guys,
I’ve stumbled into an issue in the past day where I have developed a small process in JavaScript that takes in information that the user has entered, and uses a combination of JavaScript and jQuery to return results. Workflow such as:
- User enters location details
- Javascript onClick function to submit to an internal js function
- Use GDownloadUrl to download an XML file on the fly for data processing
- Process data
- Use jQuery to output results into a div
I am using variable functions such as:
var search = {
performSearch: function() {
...
...
}
}
It all worked in Firefox when I was debugging with Firebug, however as soon as I stop using firebug it doesn’t do anything. I’ve tested it by putting alert() statements in different parts of the code - if the alerts are near the start of the process everything works as expected though if added at the end nothing happens.
I’ve looked at this in IE 8 and it’s working perfectly! (which is a nice surprise!)
Can anyone suggest what’s the problem??
Many thanks
p.s. is there a way of closing this post, and marking it as solved?
Of course!
Thanks siteguru - I didn’t appreciate the difference in speed, and plus I’ve had my head stuck in it for the past 24hrs and couldn’t see the obvious.
Instead of using:
GDownloadUrl(location, function (data, responseCode) {
var xml = GXml.parse(data);
.....
Which appeared to open the file though not necessarily fire the code off as expected. I’ve changed it to only execute after onload:
loadXMLSiteForecast: function() {
var location = "feeds/mylocations.xml";
if (window.ActiveXObject) {
search.xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
search.xmlDoc=document.implementation.createDocument("","",null);
} else {
alert('Your browser cannot handle this script');
}
search.xmlDoc.async=false;
search.xmlDoc.load(location);
search.xmlDoc.onload=search.matchAndOutputData();
},
Thanks so much!!
Edit the original post and change the title to SOLVED? (Maybe not - I think you only get a certain time window to be able to edit old posts. Maybe a mod will do it.
)
I have changed the thread title to indicate that it contains the solution.
A timing issue with respect to the XML data call? Maybe IE8 runs slower or reacts differently to the XML return and so seems to work OK?
Without more detail/code then I guess we can only speculate. 
What about Opera or Safari or Chrome - how do they respond?