Question

I'm new to worklight, and i'm trying to get an image which is stored in mysql as a blob data. but i'm having trouble the picture won't show. here is my code

WL.Client.invokeProcedure(invocationData, {
  onSuccess: function(response){
    var result = response.invocationResult; //ini hasilnya
    if(result.isSuccessful){
      var data = result.resultSet;
      var text ='';
      $.each(data , function(index,item){
        var base64blob = item.picture;
        var image = document.createElement('img');
                image.src = 'data:image/png;base64,'+ base64blob;
                document.body.appendChild(image);
                ...
        text += '<img class="ui-li-thumb" src="' + 'data:image/jpg;base64,'+ base64blob + '"></img>';
        ...
  });
  $('#order_list').html(text);
        $('#order_list').listview('refresh');
    } else{
            alert("error");
    }
Was it helpful?

Solution

Adapters returns only a JSON object.
A BLOB is a binary large object.
You need to convert the binary object to base64 before it is sent as the response.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top