Reputation: 215
I wanted to send array to server and do check in nodejs code
function(project id){// Project id = [1,3,4,5]
var data : project id
$.ajax({
type:'POST',
url: '/checkstatus',
data: data,
}).function(done){
console.log(true);
}
}
// Could you please correct the Ajax code and as well as how do you get input in req in server side. i want to run loop in server side.
Upvotes: 1
Views: 2374
Reputation: 2353
You can achived this like this:
function(project id){// Project id = [1,3,4,5]
var data : project id
$.ajax({
type:'POST',
url: '/checkstatus',
data: JSON.stringify(data),//it will convert array to string
}).function(done){
console.log(true);
}
}
And server side convert string to array like this.
let data = JSON.parse(req.body)
Upvotes: 2