且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Javascript中通过Rest API发送Http POST请求

更新时间:2022-11-27 21:38:15

xmlhttp.send(parameters);
             ^^^^^^^^^^

那需要是字符串,但是是对象,所以会转成字符串:"[object Object]".

That needs to be a string, but it is an object, so will be converted to the string: "[object Object]".

您需要先将数据转换为正确的编码.

You need to convert the data to the proper encoding first.

你说过:

xmlhttp.setRequestHeader("Content-type", "application/json");

所以你可以使用 JSON.stringify(parameters) .