JS Send Ajax is an array of background loops to send JSON to the foreground method

Source: Internet
Author: User
Tags array length findone

Node backstage

/////////////////////////////////////////////

Router.post ("/cxhh", Function (req, res) {
Inquire
User.findone (Req.body, function (err, user) {

var hlist = []//new a new array
var j = 0;
var l=user.hh.length
for (var i = 0; i <user.hh.length ; i++) {The array length that the loop foreground sends over

User.findone ({
"_id": User.hh[i]
}, function (err, user) {

Hlist.push (user)//pushes the found data into the newly created array

J + +//push an array j+1
Console.log (User.hh.length)
if (j = = L) {Returns data to the foreground if the length of the pushed array is equal to the length of the group

Res.json ({
Data:hlist

})
}

})

}

})

})

JS Send Ajax is an array of background loops to send JSON to the foreground method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.