Im experimenting with some JQuery and timing. I use the code below just for test purpose. My problem is that my controller is only being called the first time. Subsequent calls to the method is not made. I tride making an "alert" in my javascript, it triggere each 10 secs, but my controller was never called, thus the text in ".page" never changes. Any ideas on why this is?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../Scripts/jquery-1.4.1.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
window.setInterval(Update, 10000);
});
function Update() {
var url = "/Home/GetTime";
$.get(url, function (data) {
$(".page").html(data);
});
}
</script>
<div class="page">
</div>
</body>
</html>
The method in my controller it should call:
public string GetTime()
{
return "<h1>"+DateTime.Now.ToString()+"</h1>";
}