问题描述
我试着用Dart包装我的头,在这样做时,向HTTPRequest中添加一些数据,结果很糟糕。我需要发送一个参数与这个请求,所以我想sendData变量可能会帮助我做到这一点。文档是稀疏的,最好的这种方法,所以我知道这只是我的语法错了。任何想法为什么这不工作?
I'm trying to wrap my head around Dart, and in doing so got stumped with adding some data to an HTTPRequest. I need to send a parameter with this request, so I figured the "sendData" variable would probably help me do that. Documentation is sparse at best for this method, so for all I know it's just my syntax that's wrong. Any idea why this wouldn't work?
HttpRequest.request(url, sendData:{"rnd":rnd.millisecondsSinceEpoch}).then(onLoadSuccess).catchError(onLoadError);
目前它在html_dartium.dart中储存,位于
Currently it tanks out in html_dartium.dart at
void send([data]) native "XMLHttpRequest_send_Callback";
只告诉我String expected。它不会说出字符串的位置,所以我被骗了。
And only tells me "String expected." It doesn't say where the string is expected, so I'm stumped. Any ideas/thoughts?
推荐答案
现在无法测试,但您可能需要对sendData进行JSON.encode。
Can't test right now, but you might want to JSON.encode the sendData.
'如果指定, sendData
将以[ByteBuffer],[Blob] ,[String]或[FormData]沿着
与HttpRequest。 '
'If specified, sendData
will send data in the form of a [ByteBuffer], [Blob], [Document], [String], or [FormData] along with the HttpRequest. '
这篇关于HTTPRequest.request与sendData,似乎不能让这个工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!