在下面的代码中,我想将高度和宽度设置为50像素。
请帮我这样做。
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "InvoiceDetailsNew2.aspx/GenerateNewBarcodeImage",
data: "{'BarCodeNumber':'" + Barcode + "'}",
dataType: "json",
async: false,
success: function (data) {
var orders = JSON.parse(data.d);
//alert(data);
var height = 50;
alert(orders);
//imgContent = orders;
imgContent = "<img "
+ "src='" + "data:image/jpg;base64,"
+ orders + "'/>";
},
error: function (result) {
alert("Error in Product Loading");
}
});
答案 0 :(得分:0)
你需要做这样的事情: -
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "InvoiceDetailsNew2.aspx/GenerateNewBarcodeImage",
data: "{'BarCodeNumber':'" + Barcode + "'}",
dataType: "json",
width: "50",
height:"50",
async: false,
success: function (data) {
var orders = JSON.parse(data.d);
//alert(data);
var height = 50;
alert(orders);
//imgContent = orders;
imgContent = "<img " + "src='" + "data:image/jpg;base64," + orders + "'/>";
},
error: function (result) {
alert("Error in Product Loading");
}
});
希望有所帮助
答案 1 :(得分:0)
您可以在创建图像标记时使用内联样式。
imgContent = "<img "
+ "src='" + "data:image/jpg;base64,"
+ orders +
+ " height='50' width='50'" + "'/>";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "InvoiceDetailsNew2.aspx/GenerateNewBarcodeImage",
data: "{'BarCodeNumber':'" + Barcode + "'}",
dataType: "json",
async: false,
success: function (data) {
var orders = JSON.parse(data.d);
//alert(data);
var height = 50;
alert(orders);
//imgContent = orders;
imgContent = "<img "
+ "src='" + "data:image/jpg;base64,"
+ orders +
+ " height='50' width='50'" + "'/>";
},
error: function (result) {
alert("Error in Product Loading");
}
});
答案 2 :(得分:0)
试试这个 -
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "InvoiceDetailsNew2.aspx/GenerateNewBarcodeImage",
data: "{'BarCodeNumber':'" + Barcode + "'}",
dataType: "json",
async: false,
success: function (data) {
var orders = JSON.parse(data.d);
//alert(data);
var height = 50;
var width= 50;
alert(orders);
//imgContent = orders;
imgContent = "<img height='"+height+ "' width='"+width+"'"
+ "src='" + "data:image/jpg;base64,"
+ orders + "'/>";
},
error: function (result) {
alert("Error in Product Loading");
}
});
答案 3 :(得分:-1)
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "InvoiceDetailsNew2.aspx/GenerateNewBarcodeImage",
data: "{'BarCodeNumber':'" + Barcode + "'}",
dataType: "json",
async: false,
success: function (data) {
var orders = JSON.parse(data.d);
//alert(data);
var height = 50;
alert(orders);
//imgContent = orders;
imgContent = "<img "
+ "src='" + "data:image/jpg;base64,"
+ orders + "'/>";
$(imgContent).height(50).width(50); // set using jquery methods
},
error: function (result) {
alert("Error in Product Loading");
}
});