Node.js is there a way to send an array within a JSON response? -
i trying figure out if there way send array in json response in node.js have attached datapoints1, datapoints2 , datapoints3 within response arrays. when received ajax request, becomes string [object object],[object object]
responsearray = '{"result":{"system":"ready","allcompleted":"completed","datapoints1":"'+datapoints1+'","datapoints2":"'+datapoints2+'","datapoints3":"'+datapoints3+'"}}'; res.setheader('content-type', 'application/json'); res.type('application/json'); res.send(responsearray);
is there way can send array within json string ajax call turn array? thanks
.send
method accepts javascript object argument. don't need build string.
try with:
var responsearray = { result: { system: "ready", allcompleted: "completed", datapoints1: datapoints1, datapoints2: datapoints2, datapoints3: datapoints3 } }; /// ... res.send(responsearray);
Comments
Post a Comment