javascript variable evaluation in function
- by lamerzpua
I trying to use simile widget for own need but I'm stuck on such problem.
I have loop
for (i=0;i<15;i++){
Timeline.loadXML(function_that_return_url(),
function(xml, url) { eventSource[i].loadXML(xml, url); });
}
This code is for Timeline.loadXML:
Timeline.loadXML = function(url, f) {
var fError = function(statusText, status, xmlhttp) {
alert("Failed to load data xml from " + url + "\n" + statusText);
};
var fDone = function(xmlhttp) {
var xml = xmlhttp.responseXML;
if (!xml.documentElement && xmlhttp.responseStream) {
xml.load(xmlhttp.responseStream);
}
f(xml, url);
};
SimileAjax.XmlHttp.get(url, fError, fDone);};
When I open the page - my function
function(xml, url) { eventSource[i].loadXML(xml, url); });
is passed to loadXML method which use it inside as f(xml, url);
Problem is that i variable is not parsed as number and I receive message that eventSource[...] is not declared.
How I can evaluate i values before it will be posted as argument for the method LoadXML ?