kitsam Posted February 13, 2008 Share Posted February 13, 2008 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 More sharing options...
Synook Posted February 13, 2008 Share Posted February 13, 2008 Why would you want to get an image through AJAX? Link to comment Share on other sites More sharing options...
kitsam Posted February 13, 2008 Author Share Posted February 13, 2008 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 More sharing options...
Reg Edit Posted February 13, 2008 Share Posted February 13, 2008 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 More sharing options...
kitsam Posted February 13, 2008 Author Share Posted February 13, 2008 Base64-encode the data on the server, and decode it after receiving it on the client.Thank for your solution.If I convert the binary data to Base64 coding, whether the size of it will be larger than original?Thank you. Link to comment Share on other sites More sharing options...
jesh Posted February 13, 2008 Share Posted February 13, 2008 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 More sharing options...
kitsam Posted February 15, 2008 Author Share Posted February 15, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.