【发布时间】:2014-04-25 17:31:08
【问题描述】:
我正在使用 mvc4、Razor 和 SignalR。现在在我的cshtml中。我有
<div>
<ul id="friends"></ul>
</div>
在我的脚本中
$(function () {
//code omitted
// Reference the auto-generated proxy for the hub.
var chat = $.connection.chatHub;
chat.client.addfriend = function (name) {
// Add the message to the page.
$('#friends').append('<li><strong>' + htmlEncode(name)
+ '</strong> ' + getOnlineIcon() + '</li>');
};
function getOnlineIcon() {
return '<img id="img_logo" alt="test" src="~/Content/Images/greenDot.gif" />';
}
}
问题是我尝试了所有方法,但它从不只显示替代文本的图像。 如果我在脚本外部放置相同的标签,它可以正常工作,这意味着路径没问题。只是在脚本中有问题。也尝试了 src 上的 url.content ,但没有运气。有什么建议吗?
【问题讨论】:
标签: asp.net-mvc razor signalr-hub