【问题标题】:php image create and jquery dialogphp图像创建和jquery对话框
【发布时间】:2010-02-23 02:51:03
【问题描述】:

我希望能够在 jQuery Dialog 窗口中显示使用 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。

关于如何让它显示我创建的图像的任何建议?

真的希望有人能帮忙吗?

谢谢

【问题讨论】:

    标签: php jquery jquery-ui modal-dialog


    【解决方案1】:

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

    $.load('#yourDialogContentDiv').html('<img src="http://YOUR_PHP_IMAGE_GENERATOR_SCRIPT" />'));
    

    然后显示您的 jQuery 对话框。 快!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多