I think nowadays you can just set the withCredentials
property of the request object to true
, e.g.:
$.ajax({
type: "GET",
url: service_url,
dataType: "xml",
data: "ParamId=" + FormId.value,
processData: false,
xhrFields: {
withCredentials: true
},
error: function(XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest, textStatus, errorThrown); },
success: function(xml) { DoSomething(xml); }
});
That causes existing authentication headers/cookies to be passed along in the AJAX request, works for me. No need to do your own Base encoding, etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…