Jump to content

How the AJAX receive the binary data?


kitsam
 Share

Recommended Posts

Hello,I know I can receive the plain text by XMLHttpRequest.responseText. If the data response by server-side be a binary data (such as Image or PDF). How can I receive those data, and receive the callback notification after those data are sending finished?Thank you.

Link to comment
Share on other sites

Why would you want to get an image through AJAX?
Because I want to get an 'Event Trigger' when the image or PDF is displayed/downloaded finish. I can implement an Event Trigger after the server-side has replied the response as plain text. For example I want to do something (such as prompt a message box) after the image or PDF is loaded finish. But I only get the plain text by using XMLHttpRequest.responseText.Thank you.
Link to comment
Share on other sites

Because I want to get an 'Event Trigger' when the image or PDF is displayed/downloaded finish. I can implement an Event Trigger after the server-side has replied the response as plain text. For example I want to do something (such as prompt a message box) after the image or PDF is loaded finish. But I only get the plain text by using XMLHttpRequest.responseText.Thank you.
Base64-encode the data on the server, and decode it after receiving it on the client.
Link to comment
Share on other sites

If it's an image, you don't need AJAX to do this.

<script type="text/javascript">var myimage = new Image();myimage.onload = function() {	document.getElementById("img").src = this.src;	alert("The image is loaded!");}myimage.src = "http://w3schools.invisionzone.com/style_images/6_logo.png";</script><img id="img" />

Link to comment
Share on other sites

If it's an image, you don't need AJAX to do this.
<script type="text/javascript">var myimage = new Image();myimage.onload = function() {	document.getElementById("img").src = this.src;	alert("The image is loaded!");}myimage.src = "http://w3schools.invisionzone.com/style_images/6_logo.png";</script><img id="img" />

Nice.I have been aware that there are many ways to implement those case before AJAX approached.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...