ajax发送请求怎么添加basic auth验证信息

使用 jQuery's beforeSend 回调方法添加 HTTP header with the authentication information:http://api.jquery.com/jQuery.ajax/

beforeSend:function(xhr){ xhr.setRequestHeader ("Authorization","Basic XXXXXX");}, 
$.ajax({
    		url: url,
    		type: 'GET', 
    		dataType: 'text',
    		beforeSend: function (xhr) {
    		    xhr.setRequestHeader ("Authorization", "Basic MzQ2NTUyNTYxQHFxLmNvbToxMjM0cXdl");
    		},
  

你可能感兴趣的:(Ajax)