asp.net mvc - MVC Controller return Content instead of JSON -
i've been working on project of requirements involved json. have need return results model can used in input elements value field. can't use solution have been objects returned instead of plain text value. controller pattern have been using:
public virtual jsonresult foodata() { var fooresults = new fooqueries().foototal(); return new jsonresult { jsonrequestbehavior = jsonrequestbehavior.allowget, data = fooresults }; }
is there way use return content instead of jsonresult? i'm new .net mvc framework , having difficulty finding correct way this.
my current results formatted this:
[{ "foo", 3 }]
instead prefer plain text can use ajax request pass 3 value input elements value="" field.
ajax call using controller:
$.ajax({ type: 'get', url: $('#foovalue').data('url'), success: function (data) { $('#foovalue').val(data); } });
the data-url equivalent to:
../foocontroller/foodata
i'm using t4mvc.
return contentresult
instead of jsonresult
public virtual contentresult goodata() { var fooresults = new fooqueries().foototal(); return content(fooresults); }
Comments
Post a Comment