Help us understand the problem. What is going on with this article?

PHPとAjaxでバイナリ?

More than 3 years have passed since last update.

あるところの質問に想像働かせて答えてみる。多分画像がやりたいんだろうと思ってるんだけど、こうすかね。

html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Download Image</title>
        <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
        <script>
            function download(){
                var image = new Image();
                image.src = 'image.php'
                image.onload = function(){
                    $('#result').append(image)                      
                    alert('downloaded');
                    image = null;
                }
            }
        </script>

    </head>

    <body>
        <button onclick="download()">Download</button>
        <div id="result">
        </div>
    </body>
</html>
php
<?php
    header('Content-type: image/jpeg');
    readfile('fish.jpg'); //画像用意してね   
?>
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away