-2
我有一個數據庫,其中包含圖像的HTML源代碼。使用jQuery和Json;我想顯示圖像。這裏是我寫的代碼片段,使用jQuery和Json顯示圖像
$(document).ready(function() {
$("#domainID").click(function() {
var domain_id = $(this).val();
$("#picture").html('');
$.getJSON('/index.php/admin/show_picture/' + domain_id, function(data) {
img = "<img src=\"https://url/" + data.htmlImageFull + "\" />";
var items = [];
$.each(data, function(key, val) {
$("#picture").append(data[key].htmlImageFull);
});
});
});
});
最主要的是我將使用與它相關聯的圖像的ID檢索html源代碼。我必須在這裏做出什麼改變?我也使用MySQL來檢查與圖像關聯的ID。
和下面是HTML,
<form method="post" action="/index.php/add">
<p>
<select name="id" id="id" size="15">
<option>Select a Domain</option>
<? foreach ($unmatchedDomains as $row) {
?>
<option value="<?=$row->id?>"><?=$row->domain
?></option>
<? }?>
</select>
</td>
<select name="id" id="id">
<option style="alignment-adjust: ←">Select Something</option>
<? foreach ($some as $row) {
?>
<option value="<?=$row->id?>"><?=$row->name
?></option>
<? }?>
</select>
<input type="submit" value="Something" />
<div id="email_content"></div>
<div id="picture"></div>
</p>
<td> </td>
<td> </td>
</tr>
</table>
</form>
測試使用所提供的代碼顯示沒有圖片/圖像。
你不是追加'img'的東西。 – binarious 2012-04-05 02:23:42
這是一個真正的問題嗎? – SinistraD 2012-04-05 02:23:56
你爲什麼這麼問? – Bluetooth 2012-04-05 02:24:30