且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery的基本身份验证错误

更新时间:2023-11-30 23:50:52

该错误是说,有没有一种方法被称为连接codeBase64定义。

The error is saying that there is no method called encodeBase64 defined.

许多浏览器有一个内置的转换,从ASCII码为Base64称为BTOA:

Many browsers have a built-in conversion from ascii to base64 called btoa:

xhr.setRequestHeader('Authorization', 'Basic ' + btoa(username + ":" + password));

如果你是支持老版本浏览器,请确保有一个base64 polyfill,比如那个在http://ww.w.i$c$csnip.com/search/javascript%20dark%20$c$cs/45

If you are supporting older browsers, make sure that there is a base64 polyfill, such as the one at http://ww.w.icodesnip.com/search/javascript%20dark%20codes/45