【发布时间】:2014-01-03 14:32:28
【问题描述】:
这个问题有点像HTTPRequest.request with sendData, can't seem to get this to work 的重复,但我现在有了更多信息。这里的目标是发送一个带有查询参数的 GET 请求。我最初尝试这样发送我的请求:
HttpRequest request = new HttpRequest();
request.open("GET", _url, async:true);
request.onError.listen(_onLoadError, onError: _onLoadError);
request.send(sendData);
其中 sendData 是一个遵循查询参数正常格式的字符串(?myVariable=2&myOtherVariable=a 等),因为这是这里的最终目标。请求被发送,但我从未在任何监控工具中看到任何额外的数据(sendData)(我使用的是 Charles)。然后我尝试了:
HttpRequest request = new HttpRequest();
request.open("GET", _url + sendData, async:true);
request.onError.listen(_onLoadError, onError: _onLoadError);
request.send();
所以现在我只是将查询字符串附加到 url 本身。这按预期工作,但远非优雅。有没有更好的解决方案?
【问题讨论】: