Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php图像创建和jquery对话框_Php_Jquery_Jquery Ui_Modal Dialog - Fatal编程技术网

php图像创建和jquery对话框

php图像创建和jquery对话框,php,jquery,jquery-ui,modal-dialog,Php,Jquery,Jquery Ui,Modal Dialog,我希望能够在jQuery对话框窗口中显示使用php动态生成的图像 当我尝试这一切,我得到的是图像的二进制数据。但是在普通php页面上创建图像不是问题 我有一个简单的php脚本来创建图像 public function image() { header('Content-type: image/png'); // Create the image $im = imagecreatetruecolor(400, 400); // Create some colo

我希望能够在jQuery对话框窗口中显示使用php动态生成的图像

当我尝试这一切,我得到的是图像的二进制数据。但是在普通php页面上创建图像不是问题

我有一个简单的php脚本来创建图像

 public function image()
{
    header('Content-type: image/png');

    // Create the image
    $im = imagecreatetruecolor(400, 400);

    // Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 399, 399, $white);

    // The text to draw
    $text = 'Just some simple text...';

    $font = 'arial.ttf';

    // Add some shadow to the text
    imagettftext($im, 20, 0, 10, 40, $grey, $font, $text);

    // Add the text
    imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

    // Using imagepng() results in clearer text compared with imagejpeg()
    imagepng($im);
    imagedestroy($im);
}
创建对话框并输出html不是问题

有没有关于如何让它显示我创建的图像的建议

真的希望有人能帮忙吗


谢谢

使用$.ajax()加载图像并注入DOM:

$.load('#yourDialogContentDiv').html('<img src="http://YOUR_PHP_IMAGE_GENERATOR_SCRIPT" />'));
$.load('#yourDialogContentDiv').html('');
然后显示jQuery对话框。 普雷斯托