JSFiddle - React, Tailwind, and code Playground

by galvakojis

HTML

<img id="photo" src="" alt="Smiley face" width="42" height="42">

JavaScript

$(document).ready(function(){
	console.log('labas');
    
    // Simulate a call to Dropbox or other service that can
    // return an image as an ArrayBuffer.
    var xhr = new XMLHttpRequest();

    // Use JSFiddle logo as a sample image to avoid complicating
    // this example with cross-domain issues.
    xhr.open( "GET", "https://fiddle.jshell.net/img/logo.png", true );

    // Ask for the result as an ArrayBuffer.
    xhr.responseType = "arraybuffer";

    xhr.onload = function( e ) {
        // Obtain a blob: URL for the image data.
        var arrayBufferView = new Uint8Array( this.response );
        var blob = new Blob( [ arrayBufferView ], { type: "image/jpeg" } );
        var urlCreator = window.URL || window.webkitURL;
        var imageUrl = urlCreator.createObjectURL( blob );
        var img = document.querySelector( "#photo" );
        img.src = imageUrl;
    };

    xhr.send();
});