Guest User

Untitled

a guest
Jul 5th, 2020
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. </script>
  2.  
  3. <script>
  4. // popovers initialization - on hover
  5. $('[data-toggle="popover-hover"]').popover({
  6. html: true,
  7. trigger: 'hover',
  8. placement: 'bottom',
  9. content: function () {
  10.  
  11. var xmlHttp = new XMLHttpRequest();
  12. var formData = new FormData()
  13. formData.append("getphoto", 11);
  14. xmlHttp.open("POST", "/staff", true);
  15. xmlHttp.responseType = "blob";
  16.  
  17. xmlHttp.onload = function(oEvent) {
  18.  
  19. // Define the FileReader which is able to read the contents of Blob
  20. var reader = new FileReader();
  21.  
  22. // The magic always begins after the Blob is successfully loaded
  23. reader.onload = function () {
  24. // Since it contains the Data URI, we should remove the prefix and keep only Base64 string
  25. var b64 = reader.result.replace(/^data:.+;base64,/, '');
  26. console.log(b64); //-> "V2VsY29tZSB0byA8Yj5iYXNlNjQuZ3VydTwvYj4h"
  27. return '<img src="data:image/jpg;base64,' + b64 + '" />';
  28. };
  29.  
  30. // Since everything is set up, let’s read the Blob and store the result as Data URI
  31. reader.readAsDataURL(xmlHttp.response);
  32.  
  33. };
  34.  
  35. xmlHttp.send(formData);
  36.  
  37.  
  38.  
  39. }
  40. });
  41.  
  42. </script>
Advertisement
Add Comment
Please, Sign In to add comment