用于 HTTP 基本身份验证的纯 JavaScript 代码? [英] Pure JavaScript code for HTTP Basic Authentication?

查看:35
本文介绍了用于 HTTP 基本身份验证的纯 JavaScript 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到在纯 JavaScript 中实现 HTTP 基本身份验证客户端的参考代码,适用于 AJAX?

Where can I find reference code that implements a HTTP Basic Authentication client in pure JavaScript, suitable for AJAX?

代码的额外点或代码指针,可以独立于 YUI 等 JS 工具包使用.Java、Flash/Flex、PHP框架等不加分

Extra points for code, or pointers to code, that can be used independent of JS toolkits like YUI. No points for Java, Flash/Flex, PHP frameworks, etc.

推荐答案

XMLHttpRequest.open 方法的五参数版本允许您指定用户名和密码.(WHATWG 规范)

The five-parameter version of the XMLHttpRequest.open method allows you to specify the username and password. (WHATWG spec)

xhr.open(method, url, async, username, password)

这篇关于用于 HTTP 基本身份验证的纯 JavaScript 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆