在嵌套對象上使用JSON.stringify()的正確方法是什麼?我收到來自API調用一個壞的請求預計JSON字符串:JSON.stringify() - 嵌套對象
testData = {"credentials": {"user": "[email protected]", "password": "testpassword", "country": "us"}};
當我查看postDasta:
"{"credentials": {"user": "[email protected]", "password": "testpassword", "country": "us"}}";
$.ajax({
...
data: JSON.stringify(testData),
...
});
感謝,
Ĵ
您是否嘗試過將對象傳遞給數據而不進行字符串化?我不記得數據參數期望一個字符串。據我所知,它要麼是一個對象,要麼是一個字符串來代替get請求。 – Daedalus