YQL Parsing using Node.js , async & callbacks ...

Respected ppl ...

We are trying to parse our university results and trying to put on the cloud for the benefit of students ... eg source of parsing : http://www.vtualerts.com/results/get_res.php?usn=1MV09IS001&sem=2

This is my node.js code https://gist.github.com/SkyKOG/5b5c1f9dca4fcb8c1124

if you see the console log ... we notice that data is successfully being fetched for all semesters of a USN (student numbers) ....but the JSON is appearing for only one sem as you can see in the browser (when i do res.send)...

The things are being fetched at random ...prolly because i haven't taken care of callbacks and async ... closures...

I somehow need to wait for all the requests to complete and then form the json for the aggregated data ....

Please help me to fix this ... i have been working on this a lot ....

Regards -Akash

2 Replies
  • "prolly because i haven't taken care of callbacks and async"

    you are right!!! callback will execute for every sem separately

    see if this helps http://www.markandey.com/2012/12/how-to-get-output-of-multiple.html use function getGroupCallBackGenerator defined at here

    var timeout=15000;
    function finalCallback(alloutput) {
        //here is your final output
    cbGenerator = getGroupCallBackGenerator(timeout, finalcallback);
    for (inputsem; inputsem >= 1; inputsem--) {
        new YQL.exec(semQueryName,cbGenerator.getCallback('semQuery'+inputsem));
  • Respected sir ...

    Thanx very much for the feedback sir ...

    Im relatively new at this ... i didnt quite understand on how to integrate the suggested things with my code ... like where do i put the console.log(alloutput); and how do i formulate alloutput ....



Recent Posts

in YQL