我认为您需要纯格式:
$.ajax({ type: 'GET', url: 'url', dataType: 'json', //whatever you need beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', make_base_auth(user, password)); }, success: function () {});});function make_base_auth(user, password) { var tok = user + ':' + password; var hash = btoa(tok); return 'Basic ' + hash;}


