0

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 Answer 1

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

this should work

Sign up to request clarification or add additional context in comments.

3 Comments

To add to this - processFaq() executes the function and passes the returned value, whereas processFaq will pass the function itself
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 ??
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.