你的位置:首页 > ASP.net教程

[ASP.net教程]ajax basic 认证


 //需要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    //////// jQuery    $.ajax({      url: "http://xxx.com",      method: 'GET',      beforeSend: function (req) {        req.setRequestHeader('Authorization', auth);      },      success: function (msg) {        //构造echarts      }    });