Hier mein Code ist:convert reponse von Jquery Ajax-Aufruf (müssen 404-Fehler für gravtar behandeln) für das Erhalten Gravatar in Bildquelle
var hashEmail = md5.createHash(email);
$.get("http://www.gravatar.com/avatar/" + hashEmail + "?d=404")
.then(function(response) {
var data = 'data:image/jpeg;base64,' + response;
$('.result').html('<img src="' + data + '" class="img-circle"/><span class="username username-hide-mobile" ng-bind="'+ attributes.name +'"></span>');
}, function(response) {
return defaultProfileImage();
});
Die Antwort, die ich erhalte wie folgt:
**
% 10JFIF % 01% 01 % 01 % 01 ; ERSTELLER: gd-jpeg v1.0 (mit IJG JPEG v80), Qualität = 90˚ C % 03% 02% 02% 03% 02% 02% 03% 03% 03% 03% 04% 03% 03% 04% 05% 08% 05% 05% 04% 04% 05% 07% 07 % 06% 08% 0C% 0C% 0C% 0B% 0B% 0B% 0E% 12% 10% 0E% 11% 0E% 0B% 0B% 10% 16% 10% 11% 13% 14% 15% 15% 15 % 0C% 0F% 17% 18% 16% 14% 18% 12% 14% 15% 14 C% 01% 03% 04% 04% 05% 04% 05% 05% 05% 14% 0B% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14 11%% 08PP
**
ich bin nicht in der Lage, diese Antwort in eine Bildquelle zu konvertieren. Mache ich etwas falsch? Hier ist, was ich bereits versucht habe:
// var binaryData = [];
// binaryData.push (Antwort);
// var img = neues window.Image();
// img.src = window.URL.createObjectURL (Antwort);
// scope.bildUrl = img.src;
// scope.imageUrl = (Fenster.URL || window.webkitURL) .createObjectURL (img);
// scope.bildUrl = window.btoa (unescape (encodeURIComponent (response)));
// let blob = neuer Blob ([Antwort], {Typ: 'image/jpeg'});
// scope.bildUrl = (window.URL || window.webkitURL) .createObjectURL (blob);
// scope.imageUrl = Antwort;
// Rückgabe scope.imageUrl;
auch mit Winkel $ http-Service-Aufruf versucht, aber war immer CORS Problem so jemand mit JQuery Ajax-Aufruf zu gehen vorgeschlagen
benötigen Warum Sie ajax verwenden würden, überhaupt ein Bild zu erhalten, legen Sie einfach die direkt url. – adeneo
, um die Fehlerreaktion zu behandeln, damit, falls Gravatar doenot existiert (anstelle ihres Standard-Gravatar-Symbols), etwas anderes tun. – Varsha