Reputation: 109
Here is my code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebClient._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js" />
<script type="text/javascript" language="javascript">
var count = 0;
function Start()
{
setInterval("ReadNotification()", 1000);
}
function ReadNotification()
{
alert(++count);
}
</script>
</head>
<body onload="return Start();">
</body>
</html>
I just run this code and received a classic error:
Microsoft JScript runtime error: 'Start' is undefined
I dont't know why, because I really defined this method. How can I solve this problem ?
Thank you very much.
Upvotes: 3
Views: 42995
Reputation: 3187
Looks like the script tag for jquery is not closig properly unless you put a tag to close it, which renders those objects not readable, which gives you the error.
Code below, hope this helps.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebClient._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script>
var count = 0;
function Start()
{
setInterval("ReadNotification()", 5000);
};
function ReadNotification()
{
alert(++count);
};
</script>
</head>
<body onload="return Start();">
</body>
</html>
Upvotes: 4