问题
Here the code which i have used to show the details from JSON , All detailsshowing properly except image.When i try to show the image its not showing in the image.
JSON METHOD
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);
}
});
Here the Panel
{
xtype: 'panel',
height:'100px',
docked: 'bottom',
html:'<div align="center" style="padding-top:30px;"><img src="resources/img/icon1.png" id="myproductpic" /> <img src="resources/img/icon2.png" id="myimglocation" /></div>'
}
How to show base64 converted image in the 'myproductpic' area.Please help me to solve
回答1:
Ext.getCmp() works only for sencha touch components, here you should use
document.getElementById()
Also set the type of data in source
document.getElementById('myproductpic').src = "data:image/jpeg;base64,"+respObj[0].itemImage;
来源:https://stackoverflow.com/questions/18824693/assigning-base-64-converted-image-from-json