Gaurav Raj

Gaurav Raj

  • 1.4k
  • 475
  • 33k

How can i create notification code using with SignalR .....

Oct 17 2018 6:08 AM
i need help ....i am create notification code with using javascript which are given below... i dont know its right way or not..... but
 
How can i create notification code using with SignalR .....Please Help ME guys
 
setInterval(function () {
getNotificationCount();
}, 3000);
function getNotificationCount() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "SocialNetWebService.asmx/NotificationCount",
data: '{UserId:' +<%=user %> +'}',
dataType: "json",
success: function (data) {
var d = data.d;
if (d != "") {
var span = document.getElementById('noti_Counter');
span.style.display = "block";
$("#noti_Counter").text(d);
}
},
error: function (result) {
alert("sorry does");
}
});
 
this is my webmethod
 
public int NotificationCount(int UserId)
{
Connection cs = new Connection();
var q = from a in cs.da.NotificationCountProcedure(UserId)
select a;
return q.ToList().Count();
}
this is my part of html page
<button id="noti_Button" class="btn btn-link" onclick="getNotification();">
Notification
<span id="noti_Counter" class="badge" style="display:none"></span>
<!--SHOW NOTIFICATIONS COUNT.-->
<!--THE NOTIFICAIONS DROPDOWN BOX.-->
</button>

Answers (3)