how to show image with out symbol
hi guys i am trying submit form and get a result as jpeg on same page. how ever when click to submit button i get the some weird code instead of image hcan you guys help me here is my code
function xgetbarcode()
{
$.get('ajax_barcode.php', { barcode: $('form[name=getbarcodeform] input[name=barcode]').val(),
getarticlenumber: $('form[name=getbarcodeform] input[name=getarticlenumber]').val(),
},
function(output)
{
$('#getbarcodee').html(output).show();
});
}
<form>....
<input type="button" value="barcode" onclick="xgetbarcode();">
</form&g开发者_如何转开发t;
<div id="getbarcodee">here i get some weird symbol</div>
thanks a lot
Add a header to your php file
header('Content-Type: image/png');
and add image into div with the source to your php file
Most likely, you are returning an image from ajax_getbarcode.php, and inserting the image (binary data) into the HTML. You need to use an <img>
tag for displaying an image in HTML.
I suggest the following code.
<script type="text/javascript">
function xgetbarcode()
{
var image = '<img src="ajax_getbarcode.php?barcode=' + $('form[name=getbarcodeform] input[name=barcode]').val() + '&getarticlenumber=' + $('form[name=getbarcodeform] input[name=getarticlenumber]').val() + '"/>';
$(#getbarcodee).html(image).show();
}
</script>
<form name="getbarcodeform"> ....
<input type="button" value="barcode" onclick="xgetbarcode();">
</form>
<div id="getbarcodee"></div>
What are you returning from your ajax_barcode.php?
Image name like xyz.jpeg
you supposed to return html tag like
<img src="xyz.jpg" width="" height="" />
Because .html() replace the entire text element of it's parent.
精彩评论