//需要Base64见:http://www.webtoolkit.info/javascript-base64.html
        function make_base_auth(user, password) {
            var tok = user + ':' + password;
            var hash = Base64.encode(tok);
            return "Basic " + hash;
        }
        var auth = make_base_auth('user', 'pwd');
        // 原始JavaScript
        //xml = new XMLHttpRequest();
        //xml.setRequestHeader('Authorization', auth);
        //xml.open('GET', url)
        // jQuery
        $.ajax({
            url: "http://xxx.com",
            method: 'GET',
            beforeSend: function (req) {
                req.setRequestHeader('Authorization', auth);
            },
            success: function (msg) {
                //构造echarts

            }
        });

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2021-11-02
  • 2021-11-11
  • 2019-06-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2021-07-13
  • 2021-08-31
相关资源
相似解决方案