jquery - SignalR error converting value -
first time working signalr , i'm running issues. i'm trying asynchronously update jtable once user adds new user system. problem is, every time try submit, run error below. i'm not sure problem is, data needed populate createusermodel passed through. thoughts i'm doing wrong?
the error
{"i":"0","e":"error converting value \"userid=19&firstname=123&lastname=123&username=123&role=admin&password=123123&confirmpassword=123123&emailaddress=fakeemail%40gmail.com&phonenumber=123\" type 'myproject.models.createusermodel'.
the model i'm trying convert to
public class createusermodel { public int userid { get; set; } public string username { get; set; } public string password { get; set; } public string confirmpassword { get; set; } public string firstname { get; set; } public string lastname { get; set; } public string emailaddress { get; set; } public string phonenumber { get; set; } public string role { get; set; } public ienumerable<selectlistitem> rolesitem { { return new selectlist(userutils.getallroles()); } } }
hub
public class jtablehub : hub { public void updateusertable(createusermodel usermodel) { clients.all.updatetable(usermodel); } }
signalr code
<script type="text/javascript"> $(document).ready(function () { var chat = $.connection.jtablehub; chat.client.updatetable = function (usermodel) { $('#userstable').jtable('addrecord', { record: usermodel, clientonly: true }); }; $.connection.hub.start().done(function () { $('#btnadd').click(function () { var data = $('#adduserform').serialize(); chat.server.updateusertable(data); }); }); }); </script>
.serialize can't used sends form url encoded data. signalr supports json.
Comments
Post a Comment