Jump to content

How the AJAX receive the binary data?


kitsam

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...