1

我正在开发一个 Windows 8 应用程序,用 HTML5/JavaScript 构建它。应用程序中的部分功能需要用户身份验证。该过程是通过一个 Web 表单将数据发布回服务器端脚本,并在成功验证后返回一组 cookie。然后可以缓存这些 cookie 中的数据并用于执行其他几个 API 调用。我想使用 WinJS.xhr 来执行此操作,而不是在应用程序中嵌入网页。

首先,我假设我可以使用dataxhr 方法的参数将用户名和密码信息传递给服务器端脚本,但我不确定如何为 POST 设置格式。

其次,如果我可以让身份验证工作,有没有办法让我看到 HTTP 响应标头中返回的 cookie 内容?

4

1 回答 1

0

You should be able to encode using the FORM encoding standard. I have some sample code that is intertwined in here, but it's very simple to encode it, and set the method to "POST" rather than GET.

For cookie transfer, you should be able to pull those out of the headers and set them as appropriate.

于 2012-09-18T18:22:44.217 回答