为什么我的信号-R不能用于IE [英] Why is my signal-R not working on IE
本文介绍了为什么我的信号-R不能用于IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
某种程度上我的信号-R不能在IE上工作,可能是什么问题?它可以在Chrome上运行但在Firefox上工作。请协助。
我尝试过:
Jquery Code
Hi guys
somehow my signal-R is not working on IE, what might be the issue?It works on Chrome but not even working on Firefox. Please assist.
What I have tried:
Jquery Code
var hasNewValue = false;
$(document).ready(function () {
function setNotification(notif) {
var divHtml = "";
$(".notification").remove();
$.each(notif, function (index, item) {
divHtml += '<div class="m-list-timeline__item notification">';
divHtml += '<span class="m-list-timeline__badge"></span>';
divHtml += '<span class="m-list-timeline__text">';
divHtml += '<a href="/notifications/">' + item.Title + '</a>';
divHtml += ' </span>';
divHtml += '<span class="m-list-timeline__time">' + item.DateS + '</span>';
divHtml += '</div > ';
});
$("#divNotifications").append(divHtml);
}
var hub = $.connection.notificationHub;
$.connection.hub.start()
.done(function () {
console.log("Hub Connected!");
hub.server.getNotification(hasNewValue);
})
.fail(function () {
console.log("Could not Connect!");
});
hub.client.broadcaastNotif = function (notif, hasNewValue) {
//Does not go inside this function when using IE
setNotification(notif)
if (!hasNewValue) {
//code
} else {
//code
}
};
});
通知中心
Notification Hub
public void GetNotification(bool hasNewValue)
{
try
{
var notif = LoadNotifications();
Clients.All.broadcaastNotif(notif, hasNewValue);
}
catch (Exception ex)
{
ex.ToString();
}
}
private List<NotificationDto> LoadNotifications()
{
try
{
var client = new RestClient("http://localhost:62195");
var request = new RestRequest("http://localhost:62195" + "/api/student/getNotifications", Method.POST);
request.AddHeader(HttpRequestHeader.ContentType.ToString(), "application/json; charset=utf-8");
request.UseDefaultCredentials = true;
request.AddObject(new StudentInput()
{
StudentNumber = UserIdentity.Username()
});
var result = client.Execute<List<NotificationDto>>(request);
var data = JsonConvert.DeserializeObject<List<NotificationDto>>(result.Content);
return data;
}
catch (Exception ex)
{
string path = @"C:\Users\Public\test.txt";
using (var tw = new StreamWriter(path, true))
{
tw.WriteLine(ex.Message);
}
}
return new List<NotificationDto>();
}
推荐答案
( document ).ready( function (){
function setNotification( notif){
var divHtml = ;
(document).ready(function () { function setNotification(notif) { var divHtml = "";
( 。notification)。remove();
(".notification").remove();
.each(notif, function (index,item){
divHtml + = ' < div class =m-list-timeline__item notification>';
divHtml + = ' < span class =m-list-timeline__badge>< ; / span>';
divHtml + = ' < span class =m-list-timeline__text>';
divHtml + = ' < a href =/ notifications />' + item.Title + ' < / a>';
divHtml + = ' < / span>';
divHtml + = ' < span class =m-list-timeline__time>' + item.DateS + ' < / span>';
divHtml + = ' < / div> 跨度>;
});
.each(notif, function (index, item) { divHtml += '<div class="m-list-timeline__item notification">'; divHtml += '<span class="m-list-timeline__badge"></span>'; divHtml += '<span class="m-list-timeline__text">'; divHtml += '<a href="/notifications/">' + item.Title + '</a>'; divHtml += ' </span>'; divHtml += '<span class="m-list-timeline__time">' + item.DateS + '</span>'; divHtml += '</div > '; });
这篇关于为什么我的信号-R不能用于IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文