我按JS中的值填充对象的字段,然后使用fetch方法将其传递给数据库。我可以看到,这些fieldes有正确的值(在控制台中)。但是当我将这个JSON中的对象发送到数据库时,我会丢失这些值。这发生在日期和布尔字段中。为什么会这样?
$imageFolder = public_path("articles/assets/images/");
这是我的功能: function saveAdv(){
var advToSaveDB = new Object();
var author = new Object();
var rubric = new Object();
$(window).ready(function () {
var advertisement = JSON.parse(localStorage.getItem('advertisementToEdit'));
fillAdvFields(advertisement);
$("#save").click(function () {
advToSaveDB.id = advertisement.id;
advToSaveDB.title = $("#title").val();
advToSaveDB.text = $("#text").val();
advToSaveDB.price = $("#price").val();
rubric.id = $(".select").val();
author.id = advertisement.authorId;
advToSaveDB.author = author;
advToSaveDB.rubric = rubric;
advToSaveDB.date = advertisement.date;
var check = document.getElementById('myCheck');
// var closed = false;
if (check.checked === true) {
// closed = true;
advToSaveDB.closed = true;
}
console.log(advToSaveDB.closed);//here is true
console.log(advToSaveDB.date);//here is right value
saveAdv();
$(location).attr('href', 'http://localhost:9999/MyAdvertisements.html?id=1');
});