My Script
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var $= jQuery.noConflict();
function FillNotifications() {
$.ajax({
type: "POST",
url: "home.aspx/GetNotifications",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
var table = $("#dvNotification table").eq(0).clone(true);
var Notifications = response.d;
$("#dvNotification table").eq(0).remove();
$(Notifications).each(function () {
$(".shownotificationsid", table).html(this.shownotificationsid);
$(".notificationid", table).html(this.notificationid);
$(".subject", table).html(this.subject);
$(".message", table).html(this.message);
$("#dvNotification").append(table).append("<br />");
table = $("#dvNotification table").eq(0).clone(true);
});
}
function ShwoNotification() {
FillNotifications();
$("#divnotify").fadeIn("slow");
}
$(function () {
setInterval('ShwoNotification()', 5000);
});
$(document).ready(function () {
$("#closenotify").click(function () {
$("#divnotify").fadeOut("slow");
});
});
</script>
Repeater design Code
<div id="dvNotification">
<asp:Repeater ID="repnotification" runat="server">
<ItemTemplate>
<tr style="removed: pointer;" >
<td style="width: 50%;">
<%# Eval("subject")%>
</td>
<td style="width: 30%;"><%#Eval("message")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</div>
My Code behind(C#)
public class Notifications
{
public string shownotificationsid { get; set; }
public string notificationid { get; set; }
public string subject { get; set; }
public string message { get; set; }
}
[WebMethod]
public static List<Notifications> GetNotifications()
{
string constr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM ShowNotifications where showstatus=1 and toid=" + HttpContext.Current.Session["EmployeeId"] + ""))
{
cmd.Connection = con;
List<Notifications> notifications = new List<Notifications>();
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
notifications.Add(new Notifications
{
shownotificationsid = sdr["shownotificationsid"].ToString(),
notificationid = sdr["notificationid"].ToString(),
subject = sdr["subject"].ToString(),
message = sdr["message"].ToString(),
});
}
}
con.Close();
return notifications;
}
}
}
When I checked console on
$.ajax({
i am getting this error
VM1552:1 Uncaught SyntaxError: Unexpected end of input(…)
FillNotifications @ home.aspx:303
ShwoNotification @ home.aspx:334
(anonymous function) @ VM336:1
So please help me to find out where i did mistake.....
What I have tried:
Above Code Provided for what i tried and where did i got error....