DoJo Toolkit 未根据请求设置附加标头

发布于 2024-11-29 04:16:07 字数 647 浏览 4 评论 0原文

我正在使用 DoJo 1.6.1 访问我的 REST Web 服务。要获取 JSON 格式的响应,我需要将 Aceept 标头字段设置为 application/json

根据 DoJo 文档,这是通过在请求上设置 headers 属性来完成的,如下所示:

var xhrArgs = {
    url: "http://localhost/myservice",
    headers: { "Accept": "application/json" },
    handleAs: "json",
    load: successCallback,
    error: errorCallback
}

var deferred = dojo.xhrGet(xhrArgs);

我还使用了 dojo.io.script.get(jsonpArgs); 和同样的问题:accept 在服务器端的值为 */* 。我使用的是 Firefox 5.0.1(也尝试过 Windows 上的 Safari 和 Firefox)。

有什么建议吗?问题是什么? 提前致谢! :)

I'm using DoJo 1.6.1 for accessing my REST web service. To get the response in JSON I need to set the Aceept header field to application/json.

According to the DoJo documentation this is done by setting the headers property on the request, like to following:

var xhrArgs = {
    url: "http://localhost/myservice",
    headers: { "Accept": "application/json" },
    handleAs: "json",
    load: successCallback,
    error: errorCallback
}

var deferred = dojo.xhrGet(xhrArgs);

I also used dojo.io.script.get(jsonpArgs); with the same issue: accept is of the value */* on the server side. I'm using Firefox 5.0.1 (also tried with Safari and Firefox on Windows).

Any suggestions what the problem is?
Thanks in advance! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文