Here's the problem. i've a base64 image string which is dynamically retrieved from database via ajax.
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvsAAAJECAYAAACIHevuAAAgAElEQVR4nO3d
after retrieving the string i want to set it as the background image of a div
<div id="dragBox"></div>
try:
$('#dragBox').css('background-image', 'url(' + base64_string + ')');
basically, you just put the base64 inside url()
.
more information:"Data URI scheme" Wiki
You can simply place your image data directly into the url
parameter of the background
property in CSS.
#dragBox {
background: url(data:image/png;base64,iv[...]);
}
Here's an example: http://jsfiddle.net/uyrjs/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With