Side navigation
#15189 closed bug (migrated)
Opened July 18, 2014 08:37AM UTC
Closed October 21, 2014 12:50AM UTC
Basic Authentication does not work with JSONP
Reported by: | driz | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | ajax | Version: | 1.11.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When sending Basic Authentication credentials with an jQuery AJAX request like so:
$.ajax({
type: 'GET',
url: 'http://domain.com',
beforeSend : function(xhr) {
var credentials = btoa(username + ':' + password);
xhr.setRequestHeader("Authorization", "Basic " + credentials);
},
dataType: 'jsonp',
success: function(data) {
console.log(data);
},
});
It doesn't work because the dataType is JSONP. Changing the dataType to JSON works.
However if you need to use JSONP for CORS, you have to do the following workaround:
$.ajax({
type: 'GET',
url: 'http://username:password@domain.com',
dataType: 'jsonp',
success: function(data) {
console.log(data);
}
});
Attachments (0)
Change History (1)
Changed October 21, 2014 12:50AM UTC by comment:1
resolution: | → migrated |
---|---|
status: | new → closed |
Migrated to https://github.com/jquery/jquery/issues/1781