根据documentation,requestData可以处理ArrayBuffer参数。但是当我尝试这个时:
var buf = new ArrayBuffer(16);
var ar = new Uint8Array(buf);
for(var i = 0; i < ar.length; i++)
ar[i] = i * 10;
request = new qx.io.request.Xhr();
request.setUrl(url);
request.setRequestData(buf);
request.send();
我收到以下错误:
Error: params must be either string or object
我做错了什么?
答案 0 :(得分:1)
您必须将方法设置为POST
request.setMethod('POST');
在致电request.send()
之前。所以你的例子看起来像这样:
var buf = new ArrayBuffer(16);
var ar = new Uint8Array(buf);
for(var i = 0; i < ar.length; i++) {
ar[i] = i * 10;
}
request = new qx.io.request.Xhr().set({
url: url,
requestData: buf,
method: 'POST'
}).send();