SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Server Side Java Script Question

    I wonder if anyone on this forum has any exeriance with server side java script?

    I have a situation where I need to loop through a form post using SSJS.

    for example with php I would do it this way:

    PHP Code:
    foreach($_POST as $key => $val){
        print(
    $key.'<=>'.$val.'<br />');
        } 
    thanks

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,408
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    I assume you're talking about Node.js - are you using a framework at all (Express, Geddy)?

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes Node.js and I have been told its the version 3 of ECMA script 3. not sure about framework.

  4. #4
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,408
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    I'm afraid I can't help you much, as I'm not an expert on node.js, but if you were using Express I believe you could do something like this:
    Code JavaScript:
    req.body.forEach(function(element, index, array){
        // Do what you want with the POST data
    });
    From what I understand, doing it in plain node.js is significantly more complicated - see this link: http://blog.frankgrimm.net/2010/11/h...ta-in-node-js/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •