我想新創建的數據與此調用用ajax
function sendtovenaarData(url){
$.ajax({
url: "http://localhost:3000/" + url,
type: 'POST',
data:
{
voornaam: $("#voornaam").val(),
achternaam: $("#achternaam").val(),
beroep: $("#beroep").val(),
adres:{
streetAddress: $("#streetAddress").val(),
city: $("#city").val(),
state: $("#state").val(),
zip: $("#zip").val()
},
haardplaats: $("#haardplaats").val(),
favoriete_quote: $("#favoriete_quote").val()
}
}).done(function() {
console.log("data added");
location.reload();
}).fail(function (xhr, message, error) {
console.log(xhr, message, error);
});}
一個我希望將其保存像頂個的圖片,但它節省了張貼到我的JSON數據庫發佈的JSON對象中的對象就像底部的那個反正在那裏呢? image of saved json
我已經嘗試創建一個變量,並將adres放在那裏,但它沒有工作。感謝您的幫助
嘗試使用'JSON.stringify'增加'data'關鍵 –
使用'JSON.stringify()' – Ivan
所以不是任何數據要傳遞的之前將其保存'hello'只要 ? – sandyJoshi