【发布时间】:2014-11-20 09:57:25
【问题描述】:
我想在得到 ajax 的响应后显示图像
我有以下代码
<!DOCTYPE html>
<html>
<title> Dashboard</title>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function() {
url = "<?php echo $_GET['PATH_INFO']; ?>";
$.ajax({
type: "POST",
url: 'http://localhost:8081/fetch_image',
dataType: "JSON",
data: {
external_source: url,
},
success: function(data) {
local_image= data[0]['local_source'];
alert(local_image);
}
});
});
</script>
</head>
<body>
</body>
我不知道,如何在 ajax 请求成功时显示 local_image
我在 php 中需要这个,所以它会返回内容类型 jpeg 标题
【问题讨论】:
-
只需设置图像元素的 src 属性并将其添加到 DOM,但我不确定您的意思:
I need this in php&¬ want to return html???