Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- </script>
- <script>
- // popovers initialization - on hover
- $('[data-toggle="popover-hover"]').popover({
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- content: function () {
- var xmlHttp = new XMLHttpRequest();
- var formData = new FormData()
- formData.append("getphoto", 11);
- xmlHttp.open("POST", "/staff", true);
- xmlHttp.responseType = "blob";
- xmlHttp.onload = function(oEvent) {
- // Define the FileReader which is able to read the contents of Blob
- var reader = new FileReader();
- // The magic always begins after the Blob is successfully loaded
- reader.onload = function () {
- // Since it contains the Data URI, we should remove the prefix and keep only Base64 string
- var b64 = reader.result.replace(/^data:.+;base64,/, '');
- console.log(b64); //-> "V2VsY29tZSB0byA8Yj5iYXNlNjQuZ3VydTwvYj4h"
- return '<img src="data:image/jpg;base64,' + b64 + '" />';
- };
- // Since everything is set up, let’s read the Blob and store the result as Data URI
- reader.readAsDataURL(xmlHttp.response);
- };
- xmlHttp.send(formData);
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment