Saturday 14 September 2013

How to get an image sent from a servlet with ajax?

How to get an image sent from a servlet with ajax?

I am trying to send a string to be encoded in a qr image and return the
image on the same page.
<form action="qrservlet" method="get">
<p>create QR Code</p>
<input type="text" name="qrtext" />
<input type="submit" value="Generate QR Code" />
</form>
This works fine but it returns a new page. I'm trying to load the image in
the page itself.
$(document).ready(function(){
$("#submit").click(function(){
$.ajax({
type: "GET",
url: "qrservlet",
data: { "qrtext" : "www.mypage.com" },
success:function(result)
{
$("#content").html(result);
}
});
});
});
When I try this it returns a bunch of symbols.

No comments:

Post a Comment