When trying to update a mongoDB collection with an array value, the update fails without any error message.
This method causes the issue:
var arr = ["test","test1","test2"];
$.ajax('http://my.mongodb.com/collection?id=80a2c727de877ac9' , {
type: "PUT",
contentType: "application/json",
data: JSON.stringify({
mykey: arr
}),
success: function() {
// Do something
},
error: function(xhr) {
console.log(xhr.responseText);
}
});
However, this approach works:
$.ajax('http://my.mongodb.com/collection?id=80a2c727de877ac9' , {
type: "PUT",
contentType: "application/json",
data: JSON.stringify({
mykey: "test"
}),
success: function() {
// Do something
},
error: function(xhr) {
console.log(xhr.responseText);
}
});