FAQ
Hello noders

i am trying to generate a chart (using highcharts) with queried data from
Mysql.
I have my data.php file to query the database and create a JSON file. This
JSON file is used by index.php file to draw the chart.
This is not working because the chart is drawn before the sql data is
retrieved.

I am trying to create a nodejs for the same and i assume this is the
solution to my requirement

Any advice here




--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/45d94ac8-d439-4d84-93d8-6fe1e215980f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Aredridel at Nov 18, 2014 at 3:02 pm
    On Nov 18, 2014 2:51 AM, Vasa <vijayaraj.rajasekar@gmail.= com> wrote:

    >
    Hello noders >
    i am trying to generate a chart (using highcharts) with queried data f= rom Mysql. [Snip] >
    This is not working because the chart is drawn before t= he sql data is retrieved. This is common
    as people start getting going in node. Move t= he drawing parts into the callback for the SQL
    query, so it waits until the= data arrives. Unlike php, request handlers don't just run to the
    bottom an= d stop. Instead, the top level is run which sets things up, which load data= , which
    set things up and finally respond. Http responses aren't done until= red.end(). That can be
    delayed as much as you need. Next, you'll start nesting deeply, so http://callbackhell.co= m
    will be a short, good read for you. Good luck! Aria

    --

    Job board: http://jobs.nodejs.org/On Nov 18, 2014 2:51 AM, Vasa
    <vijayaraj.rajasekar@gmail.= com> wrote:

    >
    Hello noders >
    i am trying to generate a chart (using highcharts) with queried data f= rom Mysql. [Snip] >
    This is not working because the chart is drawn before t= he sql data is retrieved. This is common
    as people start getting going in node. Move t= he drawing parts into the callback for the SQL
    query, so it waits until the= data arrives. Unlike php, request handlers don't just run to the
    bottom an= d stop. Instead, the top level is run which sets things up, which load data= , which
    set things up and finally respond. Http responses aren't done until= red.end(). That can be
    delayed as much as you need. Next, you'll start nesting deeply, so http://callbackhell.co= m
    will be a short, good read for you. Good luck! Aria
  • Vasa at Nov 19, 2014 at 1:36 pm
    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and my
    PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a request
    is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data from
    Mysql.
    I have my data.php file to query the database and create a JSON file. This
    JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here



    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/cc403d67-c255-4edd-9a32-0fc6868f23af%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Christopher Rust at Nov 19, 2014 at 6:09 pm
    Every time you have a function that you want to run first, that makes use
    of callbacks, such as:

    myFunc(function(err, result) { ... });

    Then you need to place the code you want to run second where ... is. This
    is the asynchronous nature of node. Any code where ... is will not run
    until myFunc is finished internally and calls it's argument function. If
    there's another synchronous function, meaning it doesn't accept a function
    as a parameter, outside of myFunc it will be run first. Otherwise they will
    be driven in order of the events caused by the user.

    dbclient.query() needs to be inside of the anonymous (read: unnamed)
    function that's passed to dbclient.connect()
    On Nov 19, 2014 7:36 AM, "Vasa" wrote:

    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and my
    PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a
    request is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data from
    Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here




    --
    Job board: http://jobs.nodejs.org/
    New group rules:
    https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/nodejs/cc403d67-c255-4edd-9a32-0fc6868f23af%40googlegroups.com
    <https://groups.google.com/d/msgid/nodejs/cc403d67-c255-4edd-9a32-0fc6868f23af%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAMT%3Dzo5cM_fYL70tBsbC_O%2Bwpf1VwfO0Th6YMXE2FO1tj8_0sQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Vasa at Nov 20, 2014 at 3:36 pm
    Thank you for your reply.
    On Wednesday, November 19, 2014 11:39:11 PM UTC+5:30, Chris Rust wrote:

    Every time you have a function that you want to run first, that makes use
    of callbacks, such as:

    myFunc(function(err, result) { ... });

    Then you need to place the code you want to run second where ... is. This
    is the asynchronous nature of node. Any code where ... is will not run
    until myFunc is finished internally and calls it's argument function. If
    there's another synchronous function, meaning it doesn't accept a function
    as a parameter, outside of myFunc it will be run first. Otherwise they will
    be driven in order of the events caused by the user.

    dbclient.query() needs to be inside of the anonymous (read: unnamed)
    function that's passed to dbclient.connect()
    On Nov 19, 2014 7:36 AM, "Vasa" <vijayaraj...@gmail.com <javascript:>>
    wrote:
    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and
    my PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a
    request is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data
    from Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here




    --
    Job board: http://jobs.nodejs.org/
    New group rules:
    https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+un...@googlegroups.com <javascript:>.
    To post to this group, send email to nod...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/nodejs/cc403d67-c255-4edd-9a32-0fc6868f23af%40googlegroups.com
    <https://groups.google.com/d/msgid/nodejs/cc403d67-c255-4edd-9a32-0fc6868f23af%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/2b97a7dc-5ffe-496c-8ccf-8b6d684ee2b6%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Oliver Leics at Nov 21, 2014 at 7:55 am
    Hi Vasa,

    https://gist.github.com/oleics/36fd5049cf2f848e34a5

    It's not working and I will not finish this gist, but you can use it
    as a starting point, if you want to.

    Two random notes:

    * I see no need to require fs or socket.io. Stick to the minimum you
    need, everything else is just confusing, even if require('socket.io')
    might look cool ^^
    * Express is a shortcut for the http-module, a very very handy shortcut.

    Have fun!


    On Thu, Nov 20, 2014 at 2:24 PM, Vasa wrote:
    Thank you for your reply.
    On Wednesday, November 19, 2014 11:39:11 PM UTC+5:30, Chris Rust wrote:

    Every time you have a function that you want to run first, that makes use
    of callbacks, such as:

    myFunc(function(err, result) { ... });

    Then you need to place the code you want to run second where ... is. This
    is the asynchronous nature of node. Any code where ... is will not run until
    myFunc is finished internally and calls it's argument function. If there's
    another synchronous function, meaning it doesn't accept a function as a
    parameter, outside of myFunc it will be run first. Otherwise they will be
    driven in order of the events caused by the user.

    dbclient.query() needs to be inside of the anonymous (read: unnamed)
    function that's passed to dbclient.connect()
    On Nov 19, 2014 7:36 AM, "Vasa" wrote:

    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and
    my PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a
    request is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data
    from Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here


    --
    Job board: http://jobs.nodejs.org/
    New group rules:
    https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+un...@googlegroups.com.
    To post to this group, send email to nod...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/nodejs/cc403d67-c255-4edd-9a32-0fc6868f23af%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    Job board: http://jobs.nodejs.org/
    New group rules:
    https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/nodejs/2b97a7dc-5ffe-496c-8ccf-8b6d684ee2b6%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAOYEtUXEyg1%3Dntmsy8fani_EQi%2BmR48dhFA2vebxg_7qLRe3qg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Vasa at Nov 24, 2014 at 5:27 am
    Hello Oliver,

    Thank you for the code. This is really helpful.

    About the socketio :) i do need it in my application. I am trying to
    implement a chart that is real-time.
    nodejs server connects to my database using socket io.
    On Friday, November 21, 2014 1:25:24 PM UTC+5:30, Oliver Leics wrote:

    Hi Vasa,

    https://gist.github.com/oleics/36fd5049cf2f848e34a5

    It's not working and I will not finish this gist, but you can use it
    as a starting point, if you want to.

    Two random notes:

    * I see no need to require fs or socket.io. Stick to the minimum you
    need, everything else is just confusing, even if require('socket.io')
    might look cool ^^
    * Express is a shortcut for the http-module, a very very handy shortcut.

    Have fun!



    On Thu, Nov 20, 2014 at 2:24 PM, Vasa <vijayaraj...@gmail.com
    <javascript:>> wrote:
    Thank you for your reply.
    On Wednesday, November 19, 2014 11:39:11 PM UTC+5:30, Chris Rust wrote:

    Every time you have a function that you want to run first, that makes
    use
    of callbacks, such as:

    myFunc(function(err, result) { ... });

    Then you need to place the code you want to run second where ... is.
    This
    is the asynchronous nature of node. Any code where ... is will not run
    until
    myFunc is finished internally and calls it's argument function. If
    there's
    another synchronous function, meaning it doesn't accept a function as a
    parameter, outside of myFunc it will be run first. Otherwise they will
    be
    driven in order of the events caused by the user.

    dbclient.query() needs to be inside of the anonymous (read: unnamed)
    function that's passed to dbclient.connect()
    On Nov 19, 2014 7:36 AM, "Vasa" wrote:

    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it
    and
    my PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a
    request is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data
    from Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here


    --
    Job board: http://jobs.nodejs.org/
    New group rules:
    https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google
    Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an
    email to nodejs+un...@googlegroups.com.
    To post to this group, send email to nod...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/nodejs/cc403d67-c255-4edd-9a32-0fc6868f23af%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    Job board: http://jobs.nodejs.org/
    New group rules:
    https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+un...@googlegroups.com <javascript:>.
    To post to this group, send email to nod...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/nodejs/2b97a7dc-5ffe-496c-8ccf-8b6d684ee2b6%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/bf470b0f-212a-4751-9a8a-b114db93de62%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • // ravi at Nov 19, 2014 at 6:09 pm

    On Nov 19, 2014, at 1:35 AM, Vasa wrote:

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and my PHP is working fine retrieving the data and charting. But i am trying to move the db queries to my nodejs. So that when a request is made, it queries the db and then tries to chart the data. I have attached my node server. Please help me out.
    Vasa,

    I am curious why you have or need both PHP and NodeJS? Ignore this if you have already proceeded past that point and Aria might have a quick answer for your question above.

    Is there a typo in the above? Did you mean NodeJS where you write PHP, above?

      —ravi


    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:
    Hello noders

    i am trying to generate a chart (using highcharts) with queried data from Mysql.
    I have my data.php file to query the database and create a JSON file. This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is retrieved.

    I am trying to create a nodejs for the same and i assume this is the solution to my requirement

    Any advice here
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/6F0D26B5-A459-440B-B6AC-96AB631BB3B1%40g8o.net.
    For more options, visit https://groups.google.com/d/optout.
  • Vasa at Nov 20, 2014 at 3:36 pm
    Ravi

    I am developing an application that queries mysql database (that gets
    updated realtime) whenever there is a http request and draws a chart with
    the data. Basically i am POPULATING DATA USING SERVER SIDE CODE. I found a
    sample in php which works fine for small database. But it fails for large
    databases. The chart displays nothing for large data. So i am trying to
    create a nodejs(asynchronous) which is the solution. I have provided the
    php files and my webserver.js(nodejs). I never mentioned that my
    webserver.js is final. It has method stubs that needs to be developed. I am
    new to nodejs, PHP or for that matter Web applications. I am trying to
    learn while developing my application. Have i made myself clear. Can you
    help me out with the code

    On Wednesday, November 19, 2014 11:39:28 PM UTC+5:30, // ravi wrote:

    On Nov 19, 2014, at 1:35 AM, Vasa <vijayaraj...@gmail.com <javascript:>>
    wrote:


    Thank you for pointing out the bug. I am new to PHP :). I fixed it and my
    PHP is working fine retrieving the data and charting. But i am trying to
    move the db queries to my nodejs. So that when a request is made, it
    queries the db and then tries to chart the data. I have attached my node
    server. Please help me out.



    Vasa,

    I am curious why you have or need both PHP and NodeJS? Ignore this if you
    have already proceeded past that point and Aria might have a quick answer
    for your question above.

    Is there a typo in the above? Did you mean NodeJS where you write PHP,
    above?

    —ravi



    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data from
    Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/9b922957-2fcd-4863-868b-ea34e24ccd44%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Zladuric at Nov 20, 2014 at 12:26 pm
    Vasa,

    It seems your webserver.js is incomplete? Either that or you forgot to call
    res.end() in there.
    From what I see, you read file names the database? Then read those files?
    What do you want to do with them? Let's say you just want to respond with a
    JSON of the files you found in the directories you queried.

    You'd have to make a few changes to webserver.js.

    1. in your request handler, you have an `if(err){return;}` block. You
    should do something like `if(err) { res.status(500); res.end(err);}`. That
    would close the request (that is still waiting for you to end it after you
    went to the database).

    2. After that if block, you should do something with results. Like,
    res.json(files);. That would send back the response as content-type
    application/json and end the request.

    Hope that helps.
    On Wednesday, November 19, 2014 7:35:12 AM UTC+1, Vasa wrote:

    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and my
    PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a
    request is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data from
    Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here



    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/91248b7e-31ef-4d14-a649-961db80848b0%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Vasa at Nov 20, 2014 at 3:35 pm
    Please ignore the older webserver.js file. This is the updated one with
    method stubs that needs to be developed
    On Thursday, November 20, 2014 1:30:45 PM UTC+5:30, zladuric wrote:

    Vasa,

    It seems your webserver.js is incomplete? Either that or you forgot to
    call res.end() in there.
    From what I see, you read file names the database? Then read those files?
    What do you want to do with them? Let's say you just want to respond with a
    JSON of the files you found in the directories you queried.

    You'd have to make a few changes to webserver.js.

    1. in your request handler, you have an `if(err){return;}` block. You
    should do something like `if(err) { res.status(500); res.end(err);}`. That
    would close the request (that is still waiting for you to end it after you
    went to the database).

    2. After that if block, you should do something with results. Like,
    res.json(files);. That would send back the response as content-type
    application/json and end the request.

    Hope that helps.
    On Wednesday, November 19, 2014 7:35:12 AM UTC+1, Vasa wrote:

    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and
    my PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a
    request is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data
    from Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here



    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/24108475-20f7-4efc-92ee-770d705af239%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Vasa at Nov 20, 2014 at 3:36 pm
    Hello zladuric,

    Thank you for your inputs. I know my webserver.js (which is my nodejs file)
    is incomplete. I have just included method stubs that needs to be
    developed.

    Alright, let me explain what i am trying to do.

               I am developing an application that queries mysql database (that
    gets updated realtime) whenever
               there is a http request and draws a chart with the data.
      Basically i am POPULATING DATA USING SERVER
               SIDE CODE. I found a sample in php which works fine for small
    database. But it fails for large databases.
               The chart displays nothing for large data. So i am trying to
    create a nodejs(asynchronous) which is the solution.

    Can you make the changes in the webserver.js file and post it here. That
    would be of great help to any beginner here. Thanks again

    On Thursday, November 20, 2014 1:30:45 PM UTC+5:30, zladuric wrote:

    Vasa,

    It seems your webserver.js is incomplete? Either that or you forgot to
    call res.end() in there.
    From what I see, you read file names the database? Then read those files?
    What do you want to do with them? Let's say you just want to respond with a
    JSON of the files you found in the directories you queried.

    You'd have to make a few changes to webserver.js.

    1. in your request handler, you have an `if(err){return;}` block. You
    should do something like `if(err) { res.status(500); res.end(err);}`. That
    would close the request (that is still waiting for you to end it after you
    went to the database).

    2. After that if block, you should do something with results. Like,
    res.json(files);. That would send back the response as content-type
    application/json and end the request.

    Hope that helps.
    On Wednesday, November 19, 2014 7:35:12 AM UTC+1, Vasa wrote:

    Hello Aria,

    Thank you for pointing out the bug. I am new to PHP :). I fixed it and
    my PHP is working fine retrieving the data and charting.
    But i am trying to move the db queries to my nodejs. So that when a
    request is made, it queries the db and then tries to chart the data.
    I have attached my node server. Please help me out.

    On Tuesday, November 18, 2014 1:21:53 PM UTC+5:30, Vasa wrote:

    Hello noders

    i am trying to generate a chart (using highcharts) with queried data
    from Mysql.
    I have my data.php file to query the database and create a JSON file.
    This JSON file is used by index.php file to draw the chart.
    This is not working because the chart is drawn before the sql data is
    retrieved.

    I am trying to create a nodejs for the same and i assume this is the
    solution to my requirement

    Any advice here



    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/1eef451a-543e-4b64-9bf9-a2675a96864f%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedNov 18, '14 at 1:26p
activeNov 24, '14 at 5:27a
posts12
users6
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase