views:

25

answers:

1

Hi there,

I seem to have an issue passing the xml i am reading to a function.. Basically i have this, this seems to work

    $.get("content/xml/faq.xml", function(test) {
        alert(test);// TEST CONTAINS THE XML
    });

but i really want to isolate the function and have the get call a new function but "data" in my function is undefined. I do end up in processFaq so the call back is working but data is empty

    $.get("content/xml/faq.xml", processFaq());

    function processFaq(data) {
       alert(data);  // DATA IS UNDEFINED
    }

Anybody know what i am doing wrong?

Thanks in advance

+1  A: 
 $.get("content/xml/faq.xml", processFaq);

this should work

antpaw
To add to this - `processFaq()` executes the function and passes the returned value, whereas `processFaq` will pass the function itself
K Prime
Thanks antpaw, i am little confused so when i passed processFaq() - notice the brakets it didn't work but without brackets it did work.. I thought i supposed to always use brackets when calling a function ??
mark smith
im not sure but i think somewhere inside the get function defenition its using eval(callback_function_name + '(data)'), but your right it needs to be more consistent
antpaw