我如何用纯javascript写下面的代码?
jQuery.post('/cart/add.js',
{ quantity: 1, id: 26449060865 },
{ quantity: 2, id: 26449101569 },
{ quantity: 3, id: 26449251265 },
null,
"json"
);发布于 2019-05-16 07:55:00
但我建议你去拿。
如果你想使用XMLHttpRequest,下面是代码。
const theUrl = "/cart/add";
xmlhttp.open("POST", theUrl);
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.send(JSON.stringify(
{ quantity: 1, id: 26449060865 },
{ quantity: 2, id: 26449101569 },
{ quantity: 3, id: 26449251265 }
)); ```https://stackoverflow.com/questions/56158385
复制相似问题