c# - Create Json Object (trying) -
so have object want send in json format (model)
function serachclient() { var tempfirstname = $("#firstname").val(); var templastname = $("#lastname").val(); var tempmobile = $("#mobile").val(); var tempaccountid = $("#accountid").val(); var temppin = "1234"; var model = { lastname: templastname, firstname: tempfirstname, mobile: tempmobile, accountid: tempaccountid, pin: temppin } $.ajax({ url: "/home/searchclient/", type: 'get', data: { model: json.stringify(model) }, cache: false, crossdomain: true, async: true, datatype: 'json', success: function (data) { }, error: function (event) { }, headers: { 'access-control-allow-origin': '*' }, }).done(function () { }); }
however on asp.net mvc controller sees
public jsonresult searchclient(string model) { } model=%7b%22lastname%22%3a%22smith%22%2c%22firstname%22%3a%22john%22%2c%22mobile%22%3a%2278121212166%22%2c%22accountid%22%3a%224e82dbfe-2b7f-472c-b66c-0707b1d66ba2%22%2c%22pin%22%3a%221234%22%7d&_=1469706173642
any ideas on why not formatting correctly?
the method converts characters url encoded characters. (see: http://www.w3schools.com/tags/ref_urlencode.asp)
could try using post in stead of get? (get limited in size)
Comments
Post a Comment