Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用 Dart 发送一个 AJAX 请求。我希望对该请求的正文进行 URL 编码,就像提交表单一样。我想设置 mime 类型来表明这一点。我该怎么做?
我尝试设置mimeType请求,但这没有帮助。
mimeType
这是代码:
HttpRequest.request(url, mimeType: 'application/x-www-form-urlencoded', sendData: myUrlEncodedString);
不要使用mimeType,而是使用requestHeaders. 这是一个例子:
requestHeaders
HttpRequest.request(url, requestHeaders: {'Content-Type': 'application/x-www-form-urlencoded'}, sendData: 'hello=world&welcome=todart');