java - signalR javascript runtime Object does not support property -
i c# algorithmic programmer trying integrate signalr
can send progress messages on long running codes.
the following simple prototype fails on
helloconnection.sayhellotoall("hello all!");
with javascript error "object doesn't support property......" although right click on helloconnection
. shows method. no similar instance of message have found applies example.
please can help: have spent weeks of frustration trying make work. here client. in master page because messages go on header.
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1"> <link href="styles/siteblue.css" rel="stylesheet" e="text/css" /> <title> seeker-home page</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script> <script src="scripts/json2.js"></script> <script src="scripts/jquery.signalr-2.2.0.js"></script> <script src="signalr/hubs"></script> <script type="text/javascript"> $(); //document ready var helloconnection = $.connection.seekerhub; helloconnection.client.sayhellotome = function (message) { alert(message); }; $.connection.hub.start().done(function () { helloconnection.sayhellotoall("hello all!"); }); function displaypopup() { alert("hello, world."); }; </script>
and here hub
using microsoft.aspnet.signalr; using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui.webcontrols; namespace signalr { public class seekerhub : hub { public void sayhellotoall(string message) { clients.all.sayhellotome(message); var callingclient = context.connectionid; } } }
thanks in advance can give me.
the problem trying call client method sayhellotome
client.
replace line of code:
helloconnection.client.sayhellotome = function (message) { alert(message); };
with this:
helloconnection.on('sayhellotome ', function(message) { alert(message); });
this way have handler on client side listening server side trigger being sayhellotome
Comments
Post a Comment