2.2.5.Passing parameters to server method from client
1.Modify the server method: add a string parameter
[HubName("myhub")]
public class MyHub:Hub
{
public string serverMethod(string msg)
{
return msg + " good morning";
}
public MyHub()
{
//
// TODO: Add constructor logic here
//
}
}
2.Modify html file: alert the string from the server
If method works it will go to done()
<script> $(document).ready(function () { var obj = $.connection.myhub; $.connection.hub.start().done(function () { obj.server.serverMethod("Hi").done(function (data) { alert(data); }); }).fail(function () { alert("No Connected"); }); }); </script>
Previous2.2.4.Create A server method and calling from clientNext2.2.6.Creating a client method and calling from server
Last updated
Was this helpful?