javascript variable evaluation in function

Posted by lamerzpua on Stack Overflow See other posts from Stack Overflow or by lamerzpua
Published on 2012-10-02T21:35:44Z Indexed on 2012/10/02 21:37 UTC
Read the original article Hit count: 322

Filed under:
|
|
|
|

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 ?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery