2013-09-16 3 views
0

Вот код, который я использовал, чтобы показать детали от JSON, Все детали покажутся правильно, кроме image.When я пытаюсь показать изображение, которое не отображается на изображении.Назначение Base 64 преобразованное изображение из JSON

JSON МЕТОД

Ext.Ajax.request({ 
    url: App.gvars.apiurl + 'ShowItemsByItemID/userID='+App.gvars.userid+'/itemID='+itemID, // url : this.getUrl(), 
    method: "GET", 
    useDefaultXhrHeader: false, 
    withCredentials: true, 
    success: function (response) { 
     var respObj = Ext.JSON.decode(response.responseText); 
     Ext.getCmp('myitemname').setValue(respObj[0].itemName); 
     Ext.getCmp('myitemdesc').setValue(respObj[0].itemDesc); 
     Ext.getCmp('myitemprice').setValue(respObj[0].itemPrice); 
     Ext.getCmp('myshopurl').setValue(respObj[0].itemAddress); 
     Ext.getCmp('myproductpic').setValue(respObj[0].itemImage); //Here the image getting  
    }, 
    failure: function (response) { 
     alert(response.responseText); 
    } 
    }); 

Здесь панель

{ 
    xtype: 'panel', 
    height:'100px', 
    docked: 'bottom', 
    html:'<div align="center" style="padding-top:30px;"><img src="resources/img/icon1.png" id="myproductpic" />&nbsp;&nbsp;&nbsp;&nbsp;<img src="resources/img/icon2.png" id="myimglocation" /></div>' 
    }  

Как показать base64 конвертируется изображение в 'myproductpic' area.Please помочь мне решить

ответ

1
Ext.getCmp() works only for sencha touch components, here you should use 

document.getElementById() 

Также установите тип данных в источнике

document.getElementById('myproductpic').src = "data:image/jpeg;base64,"+respObj[0].itemImage; 
+0

нет его не работает – Fazil

+0

@Fazil дал мне тест. сообщение, что base64 строка здесь – Viswa

+0

вы можете получить строку from pastebin.com/yVkn4rsf – Fazil

Смежные вопросы