我正在向下滾動加載中繼器。我正在嘗試顯示發件人的郵件發件人,郵件和圖片縮略圖的名稱。除了圖像以外,一切都很好。我將圖像的名稱/路徑看作文本而不是圖像本身。如何從XML提供圖像源到<img>?
[WebMethod]
public static string GetCustomers(int pageIndex, int qstr)
{
return GetCustomersData(pageIndex,qstr).GetXml();
}
XML
<Customers>
<RowNumber>11</RowNumber>
<MsgId>12</MsgId>
<sentby>Matt</sentby>
<sentTo>John</sentTo>
<Msg>ok?</Msg>
<ImageName>935604602.jpg</ImageName>
</Customers>
現在我有這樣的代碼上ASPX ..
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
pageCount = parseInt(xml.find("PageCount").eq(0).find("PageCount").text());
var customers = xml.find("Customers");
customers.each(function() {
var customer = $(this);
var table = $("#dvCustomers table").eq(0).clone(true);
$(".MsgId", table).html(customer.find("MsgId").text());
$(".sentby", table).html(customer.find("sentby").text());
$(".sentTo", table).html(customer.find("sentTo").text());
$(".Msg", table).html(customer.find("Msg").text());
$(".ImageThumb", table).html(customer.find("ImageUrl").text());
$("#dvCustomers").append(table).append("");
});
$("#loader").hide();
}
直放站代碼
<asp:Repeater ID="rptCustomers" runat="server" >
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" style="width: 400px; height: 50px;
border: dashed 0px #04AFEF; background-color:#F1EEE5">
<tr>
<td>
<b><u><span class="sentby" style="color:#A52A2A;"><%# Eval("sentby") %></span></u></b>
</td>
</tr>
<tr>
<td>
<b> <span class="ImageThumb"><img src= "<%# Eval("ImageUrl") %>" alt="Title #0" width="70" height="70" /></a></b></span>
<span class="Msg"><%# Eval("Msg")%></span>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</div>
除圖像外,一切正常。我在文本中看到圖像的名稱/路徑,而不是圖像本身。
改變你的jQuery選擇之間的不匹配。 –
你可以發佈呈現的HTML代碼嗎? –
@SandorA抓住我。比我更快:) –