weixin_33709609 2013-07-01 12:43 采纳率: 0%
浏览 58

如何在jquery ajax响应中获取更新的图像?

我正在使用GD库绘制图像,然后我将使用jquery ajax获取该图像。但是当我更新图像时,jquery ajax无法获取更新的图像,而当我检查目录时,图像却更新了——如何在jquery ajax响应中获取更新的图像?

我的用于从php文件获取响应的jquery代码如下:

jQuery.ajax({
    type: "POST", 
    url: "create.php",
    dataType:"text",
    data:myData,
    success:function(response){
        //location.reload();
        var result = response.split("|");

        document.getElementById('img').innerHTML = result[0]; // This is the image

        document.getElementById('download').innerHTML = result[1]; // this is a href link for some other purpose
    },
    error:function (xhr, ajaxOptions, thrownError){
        alert(thrownError);
    }
});

请帮助我,谢谢!

  • 写回答

3条回答 默认 最新

  • weixin_33696822 2013-07-01 12:47
    关注

    This cannot work:

    document.getElementById('img').innerHTML
    

    An image doesn't have any inner html code, you have to use the src property:

    document.getElementById('img').src = result[0];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作