问题
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);
Currently it tanks out in html_dartium.dart at
void send([data]) native "XMLHttpRequest_send_Callback";
And only tells me "String expected." It doesn't say where the string is expected, so I'm stumped. Any ideas/thoughts?
回答1:
Can't test right now, but you might want to JSON.encode the sendData.
'If specified, sendData
will send data in the form of a [ByteBuffer], [Blob], [Document], [String], or [FormData] along
with the HttpRequest. '
来源:https://stackoverflow.com/questions/19777665/httprequest-request-with-senddata-cant-seem-to-get-this-to-work