javascript returns NaN when calling server side function

remixs

New Member
Disclaimer: javascript noobI have the following javascript code that is trying to call a server side function:\[code\] function server_GetStats(nodeID) { var result = PageMethods.getStats(nodeID); return result; } setInterval(function () { newVal = parseInt(server_GetStats(1089)) + parseInt(server_GetStats(1090)); rate = (newVal - val) / (pollTime / updateCounterTime); }, pollTime);\[/code\]And this is the server side function that is being called:\[code\] [WebMethod] public static int getStats(object nodeID) { int stat= 0; SqlConnection conn = new SqlConnection(); string connStr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString(); conn.ConnectionString = connStr; conn.Open(); string sql = "SELECT stat FROM NODE_PROPERTIES WHERE NodeID = " + Int32.Parse(nodeID.ToString()); SqlCommand cmd = new SqlCommand(sql, conn); stat = Int32.Parse((cmd.ExecuteScalar().ToString())); conn.Close(); return stat; }\[/code\]I've added asp:ScriptManager to the aspx page as well. Can't for the life of me figure out why I'm getting NaN. I checked that the SQL statement is OK too. Could someone shed some light on what I'm doing wrong? Thanks in advance!!
 
Back
Top